lightmy.day

HTTP headers

Cache-Control HTTP Header Meaning

Cache-Control sets caching rules for browsers and shared caches.

Meaning

The header defines how long a response can be reused and when it must be revalidated or stored.

Where it appears

Servers send it on responses; clients can also send request directives for cache behavior.

What to check

Check max-age, shared-cache directives, no-store rules, and whether the response can safely be cached.

Example

Cache-Control: max-age=3600, stale-while-revalidate=60

Common values and directives

max-age
max-age=<seconds>Caches can reuse the response for this many seconds before revalidating.
s-maxage
s-maxage=<seconds>Shared caches use this value instead of max-age.
no-cache
Caches may store the response, but must revalidate before reuse.
no-store
Caches should not store the request or response.
private
Only a private browser cache may store the response.
public
Shared caches may store the response even when it would otherwise be restricted.
must-revalidate
Once stale, caches must revalidate before reuse.
stale-while-revalidate
stale-while-revalidate=<seconds>Caches may serve stale content briefly while refreshing it in the background.
stale-if-error
stale-if-error=<seconds>Caches may serve stale content when revalidation or origin fetch fails.

References

Related HTTP headers

Related HTTP status codes