Files
What you'll learn
- Control how long a response may be reused with Cache-Control, and tell no-cache from no-store
- Tag a representation with an ETag and answer If-None-Match with 304 Not Modified
- Prevent lost updates with If-Match, answering 412 for a stale write and 428 for one that names no version
Press Run tests to start the app. Its log appears here.Graded endpoints
max-age=3600: any cache may reuse this answer for an hour without asking again
The cat, its version as an ETag, and no-cache: keep it, but check before reusing it
The client sends back the tag it has; it is still current, so 304 and no body
If-None-Match may list several tags; one of them matching is enough
A tag only matches the resource it came from: Luna is sent in full
428 Precondition Required: a write must say which version it is replacing
412 Precondition Failed: the version the client read is not the current one
Both refused writes left Tom and his version alone
The client read version 1 and version 1 is current: the write goes through and the tag moves on
A second client also read version 1 and now tries to write: its change would erase the first, so 412
The client's cached tag is out of date, so the new version comes in full
And the new tag revalidates
404, unchanged
There is nothing to compare a tag with