Web development
Choose cache rules for HTML and versioned assets
Use different cache policies for frequently updated HTML and content-addressed assets. HTML can require revalidation, while a uniquely versioned asset can be cached for a long time.
Worked example
Worked reference example
# Illustrative response headers, configured on your host:
# HTML
Cache-Control: no-cache
# /assets/site.7b19c4.css, with a new URL whenever bytes change
Cache-Control: public, max-age=31536000, immutableHow it works
No-cache permits storage but requires validation before reuse. A versioned asset URL makes a long-lived immutable response practical because changing content gets a different address. The policy belongs in HTTP response headers from the host.
Limits and mistakes
No-cache does not mean no-store. Do not mark an unversioned file immutable if you expect its bytes to change at the same URL. Private or personalized content needs an appropriate policy rather than the public asset example.
Check the result
Inspect response headers for both an HTML page and a versioned asset. Publish a changed asset under a new URL and confirm the HTML requests the new version.
Sources
Reference documentation for the behavior used in this guide: