If-Match
The HTTP If-Match request header is used to transform the HTTP request into one that is conditional based on a set of HTTP ETag headers matching.
Usage
The If-Match request header is included by the client to indicate that the server is only to complete the HTTP request if the specified HTTP ETag headers match. In the case of safe methods, HTTP GET and HTTP HEAD, the resource will only be returned if one of the specified HTTP ETag headers matches. For unsafe methods such as HTTP PUT, the server will only accept the HTTP request if the condition is met.
A common use of If-Match is to ensure that an HTTP PUT does not overwrite recent updates. Otherwise, this results in the lost update problem. If the match is not successful then the server will return the HTTP error status code 412 Precondition Failed.
The only directive is the ETag value. Multiple HTTP ETag headers can be specified on different lines or instead as a comma-delimited list on a single line. Including the asterisk *
acts as a wildcard, meaning that every resource matches.
Note
For more information on HTTP ETag headers, in particular, concerning strong validation versus weak validation, see HTTP Conditional Requests.
Example
In this example, the HTTP request will only be processed if the ETag matches what the server has stored.
Request
If-Match: "1234567890"
Takeaway
The HTTP If-Match request header is used to transform the HTTP request into a conditional request, where the specified condition must match to complete the HTTP request.