Conditional requests in HTTP help address two problems. For
GET requests, conditional requests help clients and caches
validate that a cached representation can still be considered fresh. For
unsafe requests such as
DELETE, conditional requests provide concurrency
Not supporting conditional
GET requests reduces
performance, but in the face of concurrency, not making unsafe requests
conditional may affect the integrity of the application. In the absence of
adequate concurrency control checks, the server is susceptible to
“lost updates” and “stale deletes.” When a
client submits a request to modify or delete a resource, it does so based
on what it thinks is the current state of the resource. But under
concurrent conditions, the current state of the resource is not static.
Either the server, through some backend means, or other clients may have
updated or deleted the resource.
Concurrency control ensures the correct processing of data under concurrent operations by clients. There are two ways to implement concurrency control:
In this model, the client gets a lock, obtains the current state of the resource, makes modifications, and then releases the lock. During this process, the server prevents other clients from acquiring a lock on the same resource. Relational databases operate in this manner.
In this model, the client first gets a token. ...