Using If-Match with ETags to stop stale edits overwriting newer changes
When two editors change the same settings page, an unconditional save can let the later request silently restore older data. A strong ETag sent with an If-Match header lets the server apply an update only if the client's copy is still current. A mismatch returns 412 Precondition Failed, prompting the editor to reconcile rather than overwrite. The article includes a sample HTTP exchange, a small Node.js model demonstrating the rule, and a note that weak tags cannot satisfy If-Match. It also warns that checking the version and writing in separate steps can reintroduce races, so the check and update should be a single conditional database operation.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in