If-None-Match HTTP request header makes the request conditional. For
HEAD methods, the server will return the requested resource, with a
200 status, only if it doesn't have an
ETag matching the given ones. For other methods, the request will be processed only if the eventually existing resource's
ETag doesn't match any of the values listed.
When the condition fails for
HEAD methods, then the server must return HTTP status code 304 (Not Modified). For methods that apply server-side changes, the status code 412 (Precondition Failed) is used. Note that the server generating a 304 response MUST generate any of the following header fields that would have been sent in a 200 (OK) response to the same request: Cache-Control, Content-Location, Date, ETag, Expires, and Vary.
The comparison with the stored
ETag uses the weak comparison algorithm, meaning two files are considered identical if the content is equivalent — they don't have to be identical byte by byte. For example, two pages that differ by their creation date in the footer would still be considered identical.
When used in combination with
If-None-Match has precedence (if the server supports it).
There are two common use cases:
HEADmethods, to update a cached entity that has an associated
- For other methods, and in particular for
If-None-Matchused with the
*value can be used to save a file not known to exist, guaranteeing that another upload didn't happen before, losing the data of the previous put; this problem is a variation of the lost update problem.