Testing optimistic concurrency with ETag and If-Match

Lost updates are the quietest bug in any CRUD application: two clients read the same record, both write, and the second silently discards the first one's work. Optimistic concurrency turns that into a 412 you can handle. Most of the catalog supports it, so you can rehearse both the happy path and the conflict.

How to practise it

  1. GET a resource and keep its ETag, then PUT it back with If-Match and watch it succeed.
  2. Have a second request modify the resource, then retry the first PUT with the now-stale ETag and collect the 412.
  3. Write without an If-Match header at all and notice that nothing stops you — which is the bug this whole mechanism exists to prevent.
  4. Combine with a conditional GET: send If-None-Match and confirm the 304 when nothing has changed.
  5. Try the Retro Quest save-conflict endpoints, where the same idea is modelled as save-game versions.

APIs to try it on

Status codes involved

Other techniques

Getting started guide · All 37 mock REST APIs