What happens when two people open the same customer record, both change it, and both press Save? Without a guard, the second save overwrites the first and nobody is told. HTTP has had a standard answer for years: the server labels each version of a resource with an ETag, and the client sends that label back in an If-Match header when it writes. If the record changed in the meantime, the server refuses with 412 Precondition Failed instead of silently discarding someone’s work.
This piece walks through how that works, what the specification actually requires, and the small decisions an API team still has to make.
Last checked November 18, 2026 against RFC 9110 (HTTP Semantics, June 2022) and RFC 6585 (April 2012).
The lost update, step by step
Take a hypothetical support tool. Ana and Ben both load ticket 4182 while its server-side version is the sixth one.
| Step | Ana | Ben | Server state |
|---|---|---|---|
| 1 | Reads the ticket, sees version 6 | Reads the ticket, sees version 6 | Version 6 |
| 2 | Changes the priority and saves | Version 7, with Ana’s priority | |
| 3 | Fixes a typo in the description and saves his whole copy | Version 8: Ben’s typo fix, Ana’s priority gone |
Ben did nothing wrong. His client sent the full representation it had, which still carried the old priority. RFC 9110 names this the “lost update” problem and lists avoiding it among the reasons for strong validators (section 8.8.1). Its description of PUT makes the same point: validators returned by the server can be used “in order to prevent accidental overwrites” (section 9.3.4).
What an ETag is
An entity tag is, in the specification’s words, “an opaque validator for differentiating between multiple representations of the same resource” (section 8.8.3). The server picks the value. It can be a revision number, a hash or anything else, as long as it changes when the representation changes. Clients should not try to parse it.
Tags come in two strengths. Strong is the default; a weak tag is marked with a W/ prefix:
ETag: "v7"
ETag: W/"v7"
The difference matters for writes. Under strong comparison, two tags match only if neither is weak and their values are identical character for character. Under weak comparison, the W/ marker is ignored. RFC 9110’s own example: W/"1" and "1" do not match under strong comparison but do match under weak comparison (section 8.8.3.2).
If-Match on writes
If-Match is the guard. RFC 9110 says it “is most often used with state-changing methods (e.g., POST, PUT, DELETE) to prevent accidental overwrites” (section 13.1.1). Replaying the ticket example with it:
- Ana and Ben both receive
ETag: "v6"with theirGET. - Ana sends
PUT /tickets/4182withIf-Match: "v6". The tag matches, the write succeeds, and the response carriesETag: "v7". - Ben sends his
PUTwithIf-Match: "v6". The current tag is now"v7", the condition is false, and the server answers412 Precondition Failed.
The specification defines 412 as meaning that “one or more conditions given in the request header fields evaluated to false when tested on the server” (section 15.5.13). Ben’s client now knows the record moved and can fetch version 7, show him what changed, and let him reapply his typo fix.
Three details in section 13.1.1 are easy to miss:
- Strong comparison only. “An origin server MUST use the strong comparison function when comparing entity tags for If-Match.” A weak tag will never satisfy
If-Match, so a server that only emits weak tags cannot support this pattern for writes. - The wildcard.
If-Match: *is true if the server has any current representation of the resource. It protects against writing to something that was deleted, not against concurrent edits. - Retries that already landed. When the condition fails, the server may still answer with a 2xx if “the request is a state-changing operation that appears to have already been applied”. That covers a client whose first attempt succeeded but whose response was lost on the network. Our guide to API idempotency covers the wider retry problem.
Creating without overwriting
The mirror case is a create that must not clobber an existing resource, such as a client choosing its own ID with PUT. Here the header is If-None-Match: *, which RFC 9110 says can be used “to prevent an unsafe request method (e.g., PUT) from inadvertently modifying an existing representation” (section 13.1.2). If something already exists at that URL, the condition is false and the write is refused.
When the client has no ETag
Some clients only know when they last fetched a resource. If-Unmodified-Since “accomplishes the same purpose as If-Match for cases where the user agent does not have an entity tag” (section 13.1.4). A timestamp says when a resource last changed, not which version the client holds, so prefer ETags when you control both sides.
Making the guard mandatory
A server that accepts unconditional writes leaves the lost update problem to every client’s good behavior. RFC 6585 added a status code for refusing them: “The 428 status code indicates that the origin server requires the request to be conditional” (section 3). Its intended use is exactly the read, modify, write-back race described above, and responses using it “SHOULD explain how to resubmit the request successfully”.
| Situation | Response |
|---|---|
Write carries a matching If-Match | 2xx, with the new ETag |
Write carries a stale If-Match | 412 Precondition Failed |
| Write carries no precondition, and the API requires one | 428 Precondition Required, with instructions |
Create with If-None-Match: * where the resource exists | 412 Precondition Failed |
A 409 Conflict is a different signal. RFC 9110 uses it when the request conflicts “with the current state of the target resource” in a way the user can resolve, such as a business rule, rather than a failed header precondition (section 15.5.10). Keeping the two apart lets clients tell “someone else edited this” from “this edit is not allowed”.
If you introduce a 428 requirement on an existing endpoint, it is a breaking change for clients that never sent If-Match; treat it like any other contract change, as described in OpenAPI breaking changes.
A client loop that respects 412
GETthe resource and keep theETagnext to the data.- Send the write with
If-Matchset to that tag. - On success, replace the stored tag with the one in the response.
- On 412, fetch again, show or merge the differences, and only then retry with the new tag. Do not retry blindly with the fresh tag and the old body; that recreates the lost update with extra steps.
- On 428, add the precondition the server asks for.
On the server side, the check and the write have to be one atomic step. Comparing the tag and then writing in a separate operation reopens the race the header was meant to close. Reading from a lagging replica can also hand out a tag that is already stale, a pattern covered in database replication lag.
Reporting & Sources
Checked November 18, 2026: IETF, RFC 9110, HTTP Semantics (June 2022), sections 8.8.1, 8.8.3, 8.8.3.2, 9.3.4, 13.1.1, 13.1.2, 13.1.4, 15.5.10 and 15.5.13; IETF, RFC 6585, Additional HTTP Status Codes (April 2012), section 3. The support-ticket example, its names and version numbers are hypothetical.





