Caching and conditional requests
ETag, Last-Modified and 304
Avoid downloading unchanged bodies.
Understand the concept
An ETag is an opaque representation validator, not necessarily a hash or database version. If-None-Match checks it. An unchanged GET/HEAD can return a bodyless 304 with cache metadata, allowing reuse of a stored representation.
Last-Modified uses time-based validation with precision and clock limitations. Condition precedence matters when validators coexist. Weak ETags describe semantic equivalence, not the same guarantee as strong byte equality.
Compression and language variants affect validator design. Do not assign one validator to incompatible bodies. A 304 is not an empty successful JSON document. Browser cache views may combine a network validation response with stored content.
Reduce transfer while maintaining freshness.
Parsing a 304 response as JSON.
One topic. Three levels of depth.
HTTP/1.1 200 OK
ETag: "v1"
Cache-Control: max-age=0The first response supplies a validator.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Does 304 carry a new article body?
Show the solution and explanation
304 → reuse stored representationNo; an appropriate stored representation is needed.