If-Match
The request header that makes a write conditional: the server applies it only if the resource still has the ETag the client sends.
In more detail
If someone else changed the resource since you read it, the tags differ and the server answers 412 Precondition Failed without changing anything. It is the HTTP form of optimistic concurrency control, preventing lost updates.
Example
In the APIs course: The course service requires If-Match on PATCH.Related terms
- ETag — A response header holding an opaque tag that names one exact version of a representation, such as ETag: "1".
- 412 Precondition Failed — The HTTP status meaning a condition in the request headers, such as If-Match, was not true, so nothing was changed.
- optimistic concurrency control — A way to prevent lost updates by reading a version, preparing a change, and making the write succeed only if that version is still current.
Taught in
- HTTP Methods And Status Codes — Modern API Architecture: REST, GraphQL & gRPC
- Caching And Conditional Requests — Modern API Architecture: REST, GraphQL & gRPC