Cache-Control
The HTTP header that states the caching policy for a response, such as private, max-age=0 or no-store.
In more detail
It is a policy, not a storage command: it says who may keep the answer, for how long it stays fresh, and whether it must be checked again. Common directives are max-age for how many seconds a response stays fresh, private for one user only, no-cache for revalidate before use, and no-store for never keep a copy.
Examples
In the APIs course: The course service sends private, max-age=0 on task reads, so only a private cache may keep them and must revalidate before each reuse, and no-store on errors and authentication answers.Cache-Control: private, max-age=0Cache-Control: no-storeIn the browser: max-age=31536000, immutable says the file is fresh for a year and will never change, ideal for hashed assets. no-cache means a copy may be stored but must be revalidated with the server before each use, and no-store means never store it.Related terms
- max-age — The Cache-Control directive that says how many seconds a stored response stays fresh.
- no-store — The Cache-Control directive that tells every cache not to keep any copy of the response.
- HTTP cache — A store that keeps HTTP responses and reuses them for later requests, following the rules the server sends in Cache-Control.
- freshness — Whether a cached response may still be used without asking the server: fresh means yes, stale means it must be checked or fetched again.
- ETag — A response header holding an opaque tag that names one exact version of a representation, such as ETag: "1".
- conditional request — An HTTP request that the server carries out only if a condition in its headers is true, such as If-None-Match or If-Match.
- hashed file name — A file name that includes a hash of the file's contents, such as app.3f9a1c.js, so any change produces a new name.
- proxy buffering — When a proxy or CDN between server and browser collects a whole response before passing it on, which breaks streaming.
- stale-while-revalidate — A caching strategy that answers immediately from the cache, even if out of date, while fetching a fresh copy in the background for next time.
- CDN — A network of servers near users that keep copies of public content, such as images, and serve them quickly.
- browser cache — Copies of web responses a user's browser keeps so it does not have to download them again.
Taught in
- Headers And Content Negotiation — Modern API Architecture: REST, GraphQL & gRPC
- Caching And Conditional Requests — Modern API Architecture: REST, GraphQL & gRPC
- Cookies And CORS — Modern API Architecture: REST, GraphQL & gRPC
- Cache Storage API: Offline Strategies And Cache-First Patterns — Frontend Architecture & Web Platform
- The Fetch API: Streaming Responses, HTTP Caching And Keepalive — Frontend Architecture & Web Platform
- Streaming Endpoints: Server-Sent Events & NDJSON Feeds — Next.js 15 & Modern App Router Architecture
- Cache Invalidation And The Three Hard Cases — Scalable System Design & Distributed Architecture