How caching speeds a site up
A cached file does not have to travel again. Browser caching makes repeat visits and later pages faster. CDN caching lets a server near the visitor answer without contacting your own server at all, which cuts the response time for everyone.
Reading Cache-Control
max-age is how many seconds a browser may reuse its copy. s-maxage is the same for CDNs and overrides max-age there. no-cache means a copy may be kept but must be rechecked before each use. no-store means no copy may be kept. immutable tells the browser the file will never change, so it should not recheck it.
Sensible settings
Files with a version or fingerprint in their name, such as scripts, styles and fonts, can be cached for a year and marked immutable. HTML pages usually get a short lifetime or no-cache in the browser, with a longer lifetime at the CDN.
Common questions
- Why does the result say MISS?
- The CDN did not have a stored copy and fetched one from your server. Run the check again: a HIT on the second try means caching works, while repeated misses mean the CDN is not storing this address.
- Should HTML pages be cached?
- At the CDN, yes, when the page is the same for every visitor. In the browser, keep it short so visitors see updates.