DevToolsmith

ETag Header

The ETag response header gives a version identifier to a response, so caches can ask “has it changed?” cheaply.

Type
Response header
Category
Caching
Defined in
RFC 9110

Syntax

ETag: "<opaque-id>"  |  ETag: W/"<opaque-id>"

How ETag works

The browser stores the ETag with the response and sends it back in If-None-Match. If the resource hasn’t changed, the server answers 304 Not Modified with no body. A W/ prefix marks a weak ETag: the content is equivalent but not byte-for-byte identical, for example after compression.

Examples

Strong ETag (often a content hash)
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Weak ETag
ETag: W/"0815"

Common mistakes

  • Servers behind a load balancer must generate the same ETag on every machine. Apache’s old default included the file’s inode, which differs between servers and defeats caching.
  • ETags also prevent lost updates: send If-Match with the ETag on a PUT, and the server rejects it with 412 if someone else changed the resource first.

Check it

curl -sI https://example.com | grep -i '^etag:'

Paste a full set of response headers into the HTTP header checker to get every header explained and common mistakes flagged.

Related headers

  • If-None-Match: asks the server to send the resource only if its ETag differs from the ones listed.
  • Cache-Control: tells browsers, CDNs and proxies whether a response may be stored, by whom, and for how long.
  • Last-Modified: says when the resource was last changed, for revalidation and heuristic caching.

More caching headers

If-Modified-Since , Expires , Age , Vary .

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What does the ETag header do?

The ETag response header gives a version identifier to a response, so caches can ask “has it changed?” cheaply. The browser stores the ETag with the response and sends it back in If-None-Match. If the resource hasn’t changed, the server answers 304 Not Modified with no body. A W/ prefix marks a weak ETag: the content is equivalent but not byte-for-byte identical, for example after compression.

How do I see the ETag header?

Run "curl -sI https://example.com" to print a response’s headers, or open the Network tab in your browser’s dev tools and select the request. Paste the headers into the HTTP header checker on this site to get each one explained.