Web development

Understand ETag revalidation

An ETag is a validator for a particular representation of a resource. A client can send it back with If-None-Match so the server can answer 304 when the representation is unchanged.

Worked example

Worked reference example

# Initial response
HTTP/1.1 200 OK
ETag: "version-123"
Cache-Control: no-cache

# Later request header
If-None-Match: "version-123"
# If unchanged, the server may respond: 304 Not Modified

How it works

The validator lets the server avoid resending the body when the client already has the relevant representation. This works with a cache policy that permits storage and requests revalidation. The client must retain the earlier body to use a 304 meaningfully.

Limits and mistakes

Do not assume an ETag is always a cryptographic hash or globally meaningful version number. Compression and intermediaries can affect representation validators. Generate and compare validators consistently with the server or hosting platform’s rules.

Check the result

Make an initial request, retain its ETag, then issue a conditional request. Confirm unchanged content produces the expected result and changed content receives a fresh body and validator.

Sources

Reference documentation for the behavior used in this guide: