ETag

Caching

An HTTP response header containing a unique identifier for a specific version of a resource. Used for cache validation—clients send the ETag back to check if content has changed without re-downloading it.

Updated Mar 9, 2026

Full Explanation

ETags enable conditional requests. The flow: server sends a response with ETag: "abc123". Next time, the client sends If-None-Match: "abc123". If the content hasn't changed, the server responds with 304 Not Modified—no body, just headers. Saves bandwidth and speeds things up.

There are two types. Strong ETags (like "abc123") guarantee byte-for-byte identity—if two responses have the same strong ETag, they're identical. Weak ETags (like W/"abc123") indicate semantic equivalence—the content is functionally the same even if bytes differ slightly (timestamps, ads, etc.).

For CDN operations, ETags interact with caching in important ways. CDNs use them for revalidation with the origin, and they're essential for byte-range requests on large files. One gotcha: if your origin has multiple servers generating different ETags for the same content (common with Apache's inode-based ETags), you'll get cache misses on every request.

Try the interactive Conditional Request Flow animation in the course to see ETag validation in action.

Interactive Animation

Loading animation...

Examples

# Server response with ETag
HTTP/1.1 200 OK
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Content-Length: 12345

# Client conditional request
GET /style.css HTTP/1.1
If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"

# Server: content unchanged
HTTP/1.1 304 Not Modified
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
# No body sent - saves bandwidth

# Nginx: ETags are on by default
# To disable (rare): etag off;

# Generate consistent ETags from content hash
etag on;  # Uses last-modified + content-length

Video Explanation

Frequently Asked Questions

An HTTP response header containing a unique identifier for a specific version of a resource. Used for cache validation—clients send the ETag back to check if content has changed without re-downloading it.

# Server response with ETag
HTTP/1.1 200 OK
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Content-Length: 12345

# Client conditional request
GET /style.css HTTP/1.1
If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"

# Server: content unchanged
HTTP/1.1 304 Not Modified
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
# No body sent - saves bandwidth

# Nginx: ETags are on by default
# To disable (rare): etag off;

# Generate consistent ETags from content hash
etag on;  # Uses last-modified + content-length

Related CDN concepts include:

  • Age Header — A response header added by caches indicating how long (in seconds) the response has been …
  • Strong ETag — A strong ETag guarantees that two resources with the same ETag are byte-for-byte identical. Any …
  • Weak ETag — A weak ETag indicates semantic equivalence—the content is functionally the same even if bytes differ. …
  • Cache-Control — The primary HTTP header for controlling caching behavior. Tells browsers, CDNs, and proxies whether to …