Protocols Concept

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.

The short answer

A cache may serve a stored response without contacting the origin while it is fresh. Freshness is a lifetime computed when the response is stored, mainly from Cache-Control: max-age, from s-maxage in a shared cache, or from Expires minus Date. The cache compares the response's current age, including time in transit and storage, against that lifetime. If the current age is less than the freshness lifetime, the response is fresh and reusable.

When the lifetime is exhausted the response is stale. A stale response cannot be reused unless a directive permits it or the cache validates it. Validation is a conditional request carrying If-None-Match or If-Modified-Since. A 304 refreshes the stored headers and resets the age; a 200 replaces the stored response; an error may permit stale reuse under stale-if-error.

A minimal example

HTTP/1.1 200 OK
Cache-Control: public, max-age=600
Age: 120
Date: Sat, 29 Nov 2026 10:00:00 GMT
ETag: "v7"

The current age is at least 120 seconds, leaving 480 seconds of freshness. Requests in that window may be served from cache. After 600 seconds the cache revalidates:

GET /data.json HTTP/1.1
If-None-Match: "v7"

A 304 reply updates Date, Cache-Control, and Age and lets the cache serve the stored body again. A 200 reply replaces the stored body and metadata.

The directives that decide

Directive Direction Effect
max-age=N response Freshness lifetime of N seconds
s-maxage=N response Overrides max-age for shared caches
no-cache response May store, but must validate before each reuse
no-store response Must not store the request or response
private response Shared caches must not store; a browser cache may
must-revalidate response Once stale, must validate; no stale reuse
stale-while-revalidate=N response May serve stale for N seconds while revalidating
no-cache request Client requires validation before reuse

The naming is a common trap. no-cache does not mean "do not store"; it means "do not reuse without validation". no-store is the directive that forbids storage.

What changes the answer

Shared and private caches differ. A CDN-like shared cache prefers s-maxage to max-age and must not store a private response; a browser cache may store it and uses max-age. A shared cache also must not reuse a response to a request with Authorization unless the response carries public, s-maxage, or must-revalidate.

Vary changes the cache key. A response that varies on Accept-Encoding cannot satisfy a request with a different value. Request directives can force revalidation: a browser reload typically sends Cache-Control: no-cache, and a request with max-age=0 treats any stored response as stale. Heuristic freshness, often a fraction of the time since Last-Modified, may apply when no explicit expiration exists.

Edge cases

A validated response keeps its stored body but adopts the new headers and age, so freshness restarts from the 304; a new Cache-Control on the 304 applies. Unsafe methods such as POST, PUT, and DELETE invalidate stored responses for the target URI, which is why editing a resource usually makes its cached copy disappear.

must-revalidate forbids serving stale content once the response is stale, while the stale-if-error extension permits it only within its configured window. Clock skew between client and origin can make Expires unreliable, which is one reason max-age is preferred for new responses.

Practical checks

curl -sSI https://example.com/data.json
curl -sSI -H 'Cache-Control: no-cache' https://example.com/data.json

Inspect Cache-Control, Date, Age, ETag, and Vary. If both are present, subtract Age from max-age to see remaining freshness. Browser developer tools label reuse as memory or disk cache and show a 304 on revalidation; Why Does an HTTP 304 Response Have No Body? explains that response. To test the validator directly, follow Validate an ETag with curl.

Sources

Revision history

Published
Updated
— Initial publication.