Caching and conditional requests
Prevent lost updates with If-Match
Do not silently overwrite concurrent edits.
Understand the concept
A client reads a resource with ETag v7 and submits If-Match: "v7" when editing. The server applies an atomic check-and-write or returns 412 when the representation changed. Checking a field and leaving a race before the write is insufficient.
If-Match uses strong comparison. A 428 can require a missing precondition; 409 is a broader state conflict. Clear status contracts improve handling.
The client can fetch current content and offer a diff or merge. Blindly retrying the old body against a new version can still overwrite someone else’s work. Concurrency checks do not replace resource authorisation.
Protect edits across concurrent admin tabs.
Automatically overwriting with the old body after a 412.
One topic. Three levels of depth.
ETag: "v7"Version of the retrieved representation.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Is a check detached from the write sufficient?
Show the solution and explanation
Atomic condition + writeNo; another update can occur between them.