// http header · response header

ETag

Version identifier used for caching

What the ETag header does

An ETag is an opaque version identifier for a resource — change the resource, change the ETag. Clients send it back in If-None-Match to revalidate their cache, letting the server answer 304 Not Modified when nothing changed.

Example

ETag: "33a64df5"

ETag in practice

Conditional request flow

GET /app.css HTTP/1.1

HTTP/1.1 200 OK
ETag: "33a64df5"
Cache-Control: no-cache

GET /app.css HTTP/1.1
If-None-Match: "33a64df5"

HTTP/1.1 304 Not Modified

Common ETag questions and problems

What is an ETag used for?

It is a validator, an identifier for a specific version of a resource. The browser stores it and sends it back in If-None-Match. If it still matches, the server replies 304 Not Modified with no body.

Strong vs weak ETags?

A strong ETag ("abc123") means the bytes are identical. A weak one (W/"abc123") means the content is semantically the same but may differ slightly, for example after re-compression.

Why does my ETag change on every request?

Servers that include inode numbers, timestamps or process-specific data in the ETag can produce different values across servers behind a load balancer. Use a content hash or a version number.

ETag or Last-Modified?

Both are validators. ETag is more precise because it works even when the modification time is unreliable. Many servers send both.

ETag vs related headers

  • If-None-Match: If-None-Match is the request header that carries the ETag back to the server for validation.
  • Last-Modified: Last-Modified is the older, time-based validator.
  • Cache-Control: Cache-Control decides when to revalidate; ETag is how revalidation is done.

Where it's used

ETag is a response header. Response headers are sent by the server to describe the response and tell the client how to handle it.

Other response headers