Hosting · Free guide

Static website caching: browser, CDN and deployment basics

Static website caching lets a browser or delivery network reuse previously retrieved files. Effective caching makes repeat requests efficient, but the rules for HTML and versioned assets should reflect how often those files change.

By StaticLaunch · Four Media Group LLC

Distinguish browser and edge cache

A browser can reuse files locally. A CDN can serve a cached response to multiple visitors. A cache miss does not mean the website is broken, and a cache hit does not mean the browser is showing the most recent deployment.

Version assets intentionally

Build tools frequently give compiled assets content-based filenames. When the content changes, the filename changes too. These assets can often have long cache lifetimes. HTML that references those assets generally needs a different revalidation strategy.

Inspect a real response

Use developer tools to examine network requests and caching headers. Compare the actual HTML with the intended deployment and distinguish browser behavior from CDN behavior.

Example
curl -I https://your-site.pages.dev/
curl -I https://your-domain.example/

Avoid blanket cache rules

A long cache lifetime on mutable HTML can make updates appear stale. Do not cache private or personalized data publicly. Review the hosting provider's existing defaults before adding your own rules.

Troubleshoot a stale page

Confirm the latest build succeeded, compare the preview URL with your custom domain and inspect the requested response. If the browser alone has old content, use its reload tools. Purge affected cache entries only when the evidence shows it is necessary.

Common questions

Will every visitor see a deployment instantly?

Not necessarily. Browser caches, service workers and custom cache rules can affect what is seen.

Should I set every file to cache forever?

No. Long immutable caching is appropriate only when a changed file receives a new URL.

References

Provider interfaces and limits can change. Consult the original documentation before changing production settings.