Practical developer guides
HTTP ETags: revalidation and optimistic concurrency
Distinguish If-None-Match cache validation from If-Match write protection, including weak validators.
Revalidate a stored representation
An ETag identifies a selected representation according to the server's rules. A client can send If-None-Match to check whether its stored response is still usable.
On an unchanged GET, a 304 response carries no new representation body; the client uses its stored content.
GET /document
If-None-Match: "v3"
Unchanged response: 304 Not ModifiedProtect an update with If-Match
For optimistic concurrency, send the validator of the version you edited. If it no longer matches, the server can reject the update with 412.
This prevents overwriting a concurrent change only when the server actually enforces the precondition.
PUT /document
If-Match: "v3"
Server now has "v4" → 412 Precondition FailedUnderstand weak validators
An ETag beginning W/ is weak. It can support semantic revalidation, but If-Match requires strong comparison.
Do not remove W/ yourself to turn a weak validator into a strong one. Preserve the exact server-provided quoted value.
Inspect from an authorized client
Use the HTTP client only when explicitly running a request to a destination you control or may test. Cross-origin scripts may need ETag exposed through CORS.
A browser hiding the header is different from a server omitting it. Compare the network response and the readable client headers.