Set Cache-Control for HTML and versioned assets
Separate page and asset policies, then confirm a style change produces a different URL.
The problem
You change a booking button and some browsers still show the old style. A cache may hold the CSS under the same name for a long time. The HTML can also go stale when the same policy applies to every response. Match each resource's policy to how it is updated.
The tool
Cache-Control governs storage and revalidation. no-cache allows a stored response to be reused after validation. Public assets can use long lifetimes when a content change gives them a new URL.
The steps
- In staging, inspect the Cache-Control header for HTML, CSS and a sample image. Record their URLs for a comparison after deployment.
- Identify public content-addressed assets, public files with static names and responses that may contain account data. Review the groups independently.
- For a fingerprinted public file such as
site.abc123.css, considerpublic, max-age=31536000, immutablewhen no different content will occupy that URL. - For a public page that needs the newest version, try
no-cacheto require revalidation. Evaluate a policy such asno-storefor sensitive account data when storage needs to be prevented. - Change one CSS rule and publish to staging. Check that the new HTML links to a new asset and that a repeat visitor gets that version.
- Inspect headers from both the application and its CDN where applicable. A shared layer can override what you expected to send.
The real cost
Headers are part of HTTP. Budget time for deployment and checks against the real delivery path, including any CDN.
The free alternative
Without hashed filenames, start with revalidation for public assets that can change in place. Move to long lifetimes after URLs reliably change with content.
Notes
- We have not tried these steps ourselves yet. They are based on the official docs. Button names may change. If your interface differs, follow the docs.
- Keep a prior asset available while an earlier page can still reference it, especially during rolling deployments.
- Evaluate private pages separately so a shared cache cannot store account content.
Sources
Did you like this guide?
The weekly newsletter is being prepared. Leave your email and we'll send it when it launches.
We use your email only to send the newsletter. Privacy policy
