How can ETags be used for "Optimistic Concurrency Control"?

Last updated 29 June 2026

  • A GET returns an ETag (a version fingerprint). The client then sends it as If-Match on its PUT/PATCH/DELETE.

  • If the ETag still matches, the server applies the change and returns a new ETag. Otherwise it returns 412 Precondition Failed, and the client re-reads and retries, which prevents lost updates.

  • It is optimistic because no locks are held and conflicts are caught only at write time. This scales well over stateless HTTP when collisions are rare.

  • https://stackoverflow.com/questions/10014161/whats-the-restful-way-of-attaching-one-resource-to-another
All REST API interview questions