Cache busting gives every production release a reliable path from the build system to the browser, CDN, and origin. This checklist explains how to version CSS, JavaScript, fonts, and images, compare common release strategies, validate cache behavior, and roll back safely without asking users to clear their browser cache.
Overview
Stale assets usually appear when an unchanged URL points to changed content. A browser, reverse proxy cache, or edge delivery network may correctly reuse a cached response for /assets/app.js even though the file on the origin has been replaced. The result can be an old stylesheet, a JavaScript bundle that does not match the HTML, missing fonts, or a page that behaves differently for different visitors.
The most dependable website cache busting strategy changes the asset URL whenever the asset content changes. A common pattern is content-addressed or hashed filenames such as app.84c1f2.js and styles.31ab90.css. The HTML or deployment manifest then points to the new names. Old files can remain available while existing pages finish loading, and new requests receive the new version.
Cache busting is separate from cache purging. A purge removes cached objects from one or more cache layers, while asset versioning makes old URLs unnecessary for new pages. Purges can be useful for emergencies or HTML changes, but they may be asynchronous, provider-specific, or broader than intended. Versioned static assets are usually easier to test and safer to cache for longer periods.
Keep the asset URL, its cache key, and its deployment reference aligned. A CDN may include query strings, headers, cookies, or other properties in its cache key. Review CDN cache key best practices before choosing a query-string approach, especially when a reverse proxy cache sits between the CDN and your origin.
Cache-busting strategies compared
| Strategy | How it works | Strengths | Watch-outs |
|---|---|---|---|
| Hashed filenames | The build process adds a content hash to each output filename. | Strong separation between versions; works well with long-lived browser and CDN caching. | Requires generated references, a manifest, and safe handling of old files during rollout. |
| Query-string versioning | The URL changes through a value such as app.js?v=2026-11-23. | Easy to add to existing systems and templates. | CDN cache-key settings must include the query string consistently; some systems normalize or ignore it. |
| Deployment manifests | A manifest maps logical names to released asset URLs. | Useful for server-rendered applications, multi-service deployments, and precise rollbacks. | HTML, templates, and application servers must use the same release manifest. |
| Purge-based releases | The deployment invalidates cached URLs after replacing origin files. | Helpful when filenames cannot change or an emergency correction is needed. | Propagation timing, scope, rate limits, and partial failures must be monitored. |
| Short-lived HTML | HTML has a shorter freshness period, so it discovers new asset URLs sooner. | Reduces the time an old page references an old bundle. | It does not fix a stale asset URL that is already cached; HTML still needs correct validation behavior. |
For most modern build pipelines, hashed filenames plus a deployment manifest provide the clearest model. Query-string versioning can be appropriate for legacy templates or a small site, provided you confirm that the CDN and browser receive distinct cache keys. Do not assume that adding a query string changes the CDN cache key; inspect the provider or reverse proxy configuration.
Checklist by scenario
New application or build pipeline
- Configure the build to generate unique filenames for changed CSS, JavaScript, fonts, and other immutable assets.
- Generate a manifest that maps names such as
app.jsto the current hashed file. - Make server-rendered templates, client-side code, and deployment tooling read the same manifest.
- Set long freshness for versioned assets only when the URL is guaranteed to change with the content.
- Set appropriate validation or shorter freshness for HTML, manifests, and other documents that discover asset URLs.
- Confirm that the CDN and reverse proxy cache the intended content and do not vary unexpectedly on cookies or authorization headers.
Legacy site using fixed filenames
- Choose either query-string versioning or a filename-generation step before changing cache headers.
- Test whether the CDN includes query strings in its cache key and whether the origin receives the expected value.
- Change the HTML reference and the asset version in the same deployment.
- Use a targeted purge if an old fixed URL was already served with an overly long freshness period.
- Document the version format so emergency releases do not accidentally reuse an earlier value.
Emergency rollback
- Keep the previous asset files available until pages from the prior release are unlikely to request them.
- Roll back the HTML or manifest reference, not just the files at the origin.
- Do not overwrite a hashed filename with different content; publish the correct previous version under its original URL.
- Purge only the affected HTML or asset URLs when immediate correction is necessary.
- Check both a fresh browser session and a cache-warmed request after the rollback.
Fonts, images, and source maps
- Version font files when their contents or format changes, and verify that CSS references the new URLs.
- Version images when dimensions, cropping, or visual content changes; do not rely on a renamed HTML reference if the image URL remains unchanged.
- Publish source maps with the exact bundle relationship expected by browser developer tools.
- Decide whether source maps should be publicly accessible, access-controlled, or omitted from production; apply the same release discipline either way.
Service-worker-controlled sites
- Inspect the service worker's precache list and runtime caching rules; a service worker can serve content without consulting the normal HTTP cache.
- Version or update the service worker itself when its cache names, asset list, or activation logic changes.
- Test install, update, activation, offline behavior, and rollback in a clean browser profile.
- Make sure an old service worker cannot continue serving a stale application shell after the server has released a new one.
What to double-check
Inspect actual response headers rather than relying on deployment logs. For a versioned CSS or JavaScript file, check Cache-Control, the CDN cache status, the age of the response, the content type, and any ETag or Last-Modified value. Request the same URL from more than one location when possible. A cache hit is useful only if it contains the intended release.
Validate the complete dependency chain:
- Open the deployed HTML and confirm that it references the expected asset URLs.
- Request each asset directly and compare its content or digest with the build output.
- Test a cold request and a cache-warmed request through the CDN hostname.
- Check the origin response separately to identify whether the stale layer is the browser, service worker, CDN, reverse proxy, or application cache.
- Load the page with an older HTML document still open, then navigate and refresh it after deployment.
For Cloudflare caching or another CDN, review cache rules, cache-key behavior, and purge scope after changing asset URLs. A broader cache configuration can accidentally cache personalized HTML, while an overly narrow configuration can reduce the cache hit ratio without solving stale assets. For WordPress, caching plugins may rewrite asset URLs or combine files; check plugin-generated CSS and JavaScript alongside theme and plugin releases. The related WordPress caching plugin comparison can help identify which layer is generating a file.
Common mistakes
- Changing the origin file but not the URL: Existing cached responses remain valid under the old URL.
- Using a timestamp without confirming cache-key behavior: The CDN may ignore, normalize, or remove the query parameter.
- Deleting old files immediately: Visitors with older HTML, open tabs, or delayed requests may still need them.
- Publishing HTML before assets: New pages can reference files that have not reached the origin or CDN yet.
- Purging everything for every release: This can create avoidable origin load and makes cache behavior harder to assess.
- Forgetting generated files: Bundles, compressed variants, source maps, fonts, and image derivatives can each have separate URLs.
- Ignoring service workers: Browser developer tools may show a service-worker response rather than a normal network response.
- Testing only in a developer session: Disable-cache settings can hide the behavior experienced by normal visitors.
When to revisit
Review this cache-busting workflow before seasonal planning cycles, major redesigns, dependency upgrades, CDN or DNS migrations, and changes to build tooling. Revisit it after introducing a service worker, switching reverse proxy software, changing cache-control headers, enabling new compression or image transformations, or moving from fixed filenames to hashed assets.
Keep a small release test in your deployment pipeline. It should publish a candidate release, request the HTML through the production delivery path, verify that every referenced asset exists, and compare representative responses before and after cache warming. Include a rollback test at a cadence appropriate to the risk of the site. After a CDN change, measure real user-facing performance and caching behavior using the Core Web Vitals after a CDN change checklist.
Before your next deployment, use this final sequence: generate unique asset URLs, publish assets first, publish the manifest and HTML second, verify cache headers, test through the CDN, confirm service-worker behavior, retain the previous release for rollback, and record any purge performed. This turns cache busting from an emergency browser-refresh request into a repeatable part of website speed optimization.