If-Match HTTP request header makes a request conditional.
A server will only return requested resources for
HEAD methods, or upload resource for
PUT and other non-safe methods, if the resource matches one of the listed
ETag values. If the conditional does not match then the
412 (Precondition Failed) response is returned.
The comparison with the stored
ETag uses the strong comparison algorithm, meaning two files are considered identical byte by byte only. If a listed
ETag has the
W/ prefix indicating a weak entity tag, this comparison algorithm will never match it.
There are two common use cases:
HEADmethods, used in combination with a
Rangeheader, it can guarantee that the new ranges requested come from the same resource as the previous one.
- For other methods, and in particular for
If-Matchcan be used to prevent the lost update problem. It can check if the modification of a resource that the user wants to upload will not override another change that has been done since the original resource was fetched.
|Header type||Request header|
|Forbidden header name||no|