What is an ETag?
An ETag is a validator: an opaque tag the origin assigns to one version of a response, so caches can revalidate it with If-None-Match.
An ETag is an HTTP response header carrying an opaque identifier for one version of a resource. Caches use it to revalidate a stored copy: they send it back in If-None-Match, and if the resource has not changed, the origin answers 304 Not Modified with no body. RFC 9110 defines ETags as validators.
ETag: "33a64df5"
GET /pricing HTTP/1.1
If-None-Match: "33a64df5"
HTTP/1.1 304 Not ModifiedA strong ETag, like "33a64df5", changes with any change to the bytes. A weak one, W/"33a64df5", only promises semantic equivalence, so it can survive a change in compression or whitespace.
- ETags make `no-cache` and expired responses cheap to check: a 304 avoids sending the body again.
- They are more precise than `Last-Modified`, which has one-second resolution.
- Revalidation needs a stored copy. After a hard purge the CDN has nothing to revalidate and fetches the full page.
Related terms
References
- RFC 9110: HTTP Semanticshttps://www.rfc-editor.org/rfc/rfc9110
- MDN: ETaghttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag
- RFC 9111: HTTP Cachinghttps://www.rfc-editor.org/rfc/rfc9111
Warm your cache after every deploy
sitewarm requests the pages in your sitemap after a deploy and reports the cache state the CDN returns for each one, with the vantage point it was measured from.