Set Cache-Control headers so browsers can reuse files that haven't changed
Returning visitors shouldn't have to download an unchanged file again when a stored copy can do the job.
How to enable browser caching with max-age and immutable
max-agesets how long a response stays fresh, in seconds. For a file whose name changes whenever its content changes, a long lifetime withimmutablelets browsers reuse it without checking for updates while it's fresh. MDN's caching guide describes this pattern.Keep the same long-lived rule off HTML that needs frequent updates. Otherwise a browser can keep showing a stored page until its freshness lifetime ends.
What's the difference between no-cache and no-store?
no-cache allows storage but requires validation with the server before reuse. no-store tells caches not to store the response. Use no-cache for content that's updated often, so each visit gets the latest version, and no-store when no cache should keep the response at all, as the Cache-Control reference explains.
How Cache-Control headers affect CDN caching
A browser cache belongs to one user; a CDN cache can serve many users. s-maxage sets a freshness lifetime for shared caches and overrides max-age there. Use private for personalized responses that should stay out of shared caches.
Frequently asked questions
Why are old files still showing after a Cache-Control change?
A cache that already holds a fresh response may reuse it without asking your server for the new header. For an updated static file, publish a new versioned URL; use your CDN's purge controls for copies it holds.
Follow cache misses back to server response time
Website speed
Find what makes your pages slow enough that visitors leave.
TTFB
Find the delay before your server starts answering and narrow down its cause.