HTTP Caching Guide

Cache-Control directives, validators, and practical caching flows.

Cache-Control Directives

Key / CodeDescription
max-ageFreshness lifetime in seconds.
no-storeDo not store response at all.
no-cacheStore but revalidate before use.
publicCacheable by shared caches/CDNs.
privateCacheable only by the browser.
stale-while-revalidateServe stale while revalidating.

Validators

Key / CodeDescription
ETagStrong/weak identifiers for resource versions.
Last-ModifiedTimestamp of last modification.
If-None-MatchRevalidate using ETag.
If-Modified-SinceRevalidate using Last-Modified.

Example

Cache-Control: public, max-age=60, s-maxage=300, stale-while-revalidate=30
ETag: "v1-abc"
Vary: Accept-Encoding
Knowledge is power.