Cache-Control
What is Cache-Control?
Cache-Control: The dominant caching directive. Controls how/whether responses are cached by browsers, CDNs, and proxies. Cache-Control tells browsers, CDNs and proxies whether and how long they may store a response. max-age=3600 means one hour. no-store means do not keep it at all. public and private decide whether shared caches may store it.
Frequently asked questions about Cache-Control
How is Cache-Control used in practice?
For static assets with a version in the file name, such as app-3f9a2c.js, use public, max-age=31536000, immutable. The file never changes under that name, so browsers can keep it for a year.
What should you keep in mind with Cache-Control?
HTML pages need shorter lifetimes, or no-cache with revalidation, so visitors see updates quickly. Pages that show personal data should be private or no-store, so a shared cache never serves one user's account page to another. Getting these headers right is one of the cheapest performance improvements a site can make.
What does an example of Cache-Control look like?
Cache-Control: public, max-age=31536000, immutable At a glance
| Category | HTTP headers |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |