Guided task
Validate a Cached Response
Observe a 304 exchange, interpret the validator, and decide when the cache may reuse the stored body.
Start with the conditional exchange, then the comparison rule that decides it, then the freshness model that determines whether a conditional request is needed at all. Finish with a command that exposes the exchange.
Reading path
Follow the checks
- 01 Why Does an HTTP 304 Response Have No Body? A 304 response has no body because the client already holds the selected representation; the status confirms that the stored body is still valid and refreshes its metadata.
- 02 Strong and Weak ETag Comparison A weak ETag can match a byte-different representation under weak comparison, which ignores the W/ prefix and compares only the opaque tag; strong comparison requires both tags to be strong and identical.
- 03 Freshness and Validation in Cache-Control A cache can reuse a stored response without contacting the origin while that response is fresh; once it is stale, the cache must validate it conditionally unless a directive explicitly allows stale reuse.
- 04 Validate an ETag with curl An ETag check is a conditional GET: store the ETag from the first response, send it in If-None-Match with curl's --etag-compare or -H, and treat a 304 status as proof that the cached copy is still fresh. A 200 status means the validator no longer matches, so the body must be fetched again.