COMPUTER ENGINEER

Jump to examples
Blog
HTTP / HTTPS / TLS6 min study
17/ 70

Status codes · 1xx–5xx

409, 412 and 428: conflicts and lost updates

Distinguish races, ETag preconditions and business conflicts.

UnderstandStudy an examplePractise

Understand the concept

Two clients can read the same version and overwrite each other. With If-Match, a client supplies the validator it previously observed. A failed precondition can produce 412. The check and update must be atomic in the underlying data store; an unprotected read followed by a write still races.

428 means the API requires a conditional request. It can communicate a missing required precondition, whereas 412 means a supplied precondition did not hold. Do not cache 428 responses. 409 represents a conflict with the resource’s current state, such as an invalid workflow transition, not every database failure.

After 412, fetch the current representation and offer an explicit merge or review. Blind retries with an old validator do not fix the conflict. If-None-Match can produce 304 for retrieval but 412 in other methods. Validators do not replace authorisation checks.

WHEN TO USE IT

When safely updating shared editor or admin records.

COMMON PITFALL

Checking the ETag separately from writing and assuming the race is solved.

01 / PRACTICE

One topic. Three levels of depth.

HTTP / illustrative example
If-Match: "v3"

HTTP/1.1 412 Precondition Failed

The server now has v4; the stale write was rejected.

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.

02 / YOUR TURN

Try it yourself first.

You omitted If-Match on an endpoint that requires it. Choose 412 or 428.

Show the solution and explanation
Worked solution
HTTP/1.1 428 Precondition Required

The policy requires a precondition; no supplied comparison has failed yet.