HTTP Caching Guide
Cache-Control directives, validators, and practical caching flows.
Cache-Control Directives
| Key / Code | Description |
|---|---|
| max-age | Freshness lifetime in seconds. |
| no-store | Do not store response at all. |
| no-cache | Store but revalidate before use. |
| public | Cacheable by shared caches/CDNs. |
| private | Cacheable only by the browser. |
| stale-while-revalidate | Serve stale while revalidating. |
Validators
| Key / Code | Description |
|---|---|
| ETag | Strong/weak identifiers for resource versions. |
| Last-Modified | Timestamp of last modification. |
| If-None-Match | Revalidate using ETag. |
| If-Modified-Since | Revalidate using Last-Modified. |
Example
Cache-Control: public, max-age=60, s-maxage=300, stale-while-revalidate=30
ETag: "v1-abc"
Vary: Accept-EncodingKnowledge is power.