Cache busting gives browsers and CDNs a safe way to keep long-lived static assets while still delivering new CSS, JavaScript, and image files after a deployment. This guide compares query strings, hashed filenames, build-tool manifests, and deployment headers, then turns them into a reusable release checklist.
Overview
Static assets are excellent candidates for website caching because they usually change less often than HTML or API responses. A stylesheet or JavaScript bundle can be stored in the browser, a reverse proxy cache, or a CDN edge location and served without contacting the origin on every request. Long cache lifetimes can improve repeat-visit performance, reduce origin traffic, and help improve perceived responsiveness.
The difficulty appears when a file changes but its URL does not. If visitors request /assets/app.css after a redesign, their browser or CDN may still have an older response associated with that URL. Cache busting solves this by changing the asset's cache key when its contents change. The old file can remain cached, while the new file is requested under a new URL.
There are two broad approaches:
- Change the URL: Add a version query string, rename the file, or include a content hash in its filename.
- Change the caching policy: Send deployment headers or purge cached objects so the existing URL is revalidated or replaced.
Changing the URL is generally the most dependable cache-busting method because browsers and CDNs treat the new URL as a separate cache key. Purging and revalidation are still useful for emergency fixes, images with stable URLs, and systems where filenames cannot be changed.
Cache-busting methods compared
| Method | Example | Best use | Watch for |
|---|---|---|---|
| Query-string version | app.css?v=2026-10-30 | Simple sites or manual releases | Every reference must use the new version; confirm the CDN includes the query string in its cache key. |
| Filename hash | app.84f3c1.css | Modern build pipelines and immutable assets | HTML or manifests must point to the generated filename. |
| Build-tool manifest | manifest.json maps logical names to hashed files | Applications with multiple bundles or server-rendered templates | Deploy the manifest and assets as one compatible release. |
| Cache purge | Purge /assets/app.css | Emergency corrections or assets whose URL cannot change | Purge scope, propagation, and re-caching behavior vary by CDN. |
| Deployment headers | Cache-Control: no-cache | Short-lived or frequently changing files | Revalidation is not the same as downloading on every request; configure the policy deliberately. |
Checklist by scenario
For CSS and JavaScript bundles
- Choose an identifier. Prefer a content hash generated from the file contents when a build system is available. A date, release number, or manual version can work, but it is easier to forget when files are edited outside the normal deployment process.
- Generate the asset before publishing references. The HTML, template, or application code should reference the exact output filename or query-string version that exists on the server and CDN.
- Upload the new files first. Make the new assets available before switching HTML or templates to reference them. This reduces the chance that a visitor receives a page pointing to a missing file.
- Deploy the references. Update the HTML, manifest, or server-side template that loads the new asset. A new bundle is ineffective if the page still emits the old URL.
- Confirm both versions. Test the new URL and, if rollback is possible, make sure the previous asset remains available for pages that are still cached.
For hashed assets, a typical production pattern is main.84f3c1.js with a long-lived cache policy such as Cache-Control: public, max-age=31536000, immutable. Use this only when the filename changes whenever the content changes. An unchanged filename must not receive an effectively permanent policy unless you have another reliable invalidation mechanism.
For images and other files with stable URLs
Images often live at predictable paths such as /uploads/hero.webp, especially in content management systems. If replacing the file at that path, decide whether the URL can change. Renaming the image to include a version is the cleanest option when you control every reference. Otherwise, use a query string such as hero.webp?v=2, provided your browser and CDN configuration use the complete URL as the cache key.
- Check whether the image URL appears in HTML, CSS, structured data, feeds, email templates, or JavaScript.
- Change the URL or purge the specific object rather than clearing the entire site.
- Request the asset through the public hostname and verify its response headers.
- Test an old page that may still reference the previous image.
For WordPress and other CMS deployments
Use the asset-versioning feature provided by the theme or plugin system where possible. Confirm that optimization plugins, a reverse proxy cache, and the CDN do not each rewrite version parameters differently. For a theme or plugin release, clear or version generated CSS and JavaScript, then test both logged-out pages and pages affected by page caching. Keep personalized, cart, checkout, and account responses outside broad static-asset rules; cache busting does not make private HTML safe to cache publicly.
For an emergency asset rollback
- Publish a known-good asset under a new URL when possible.
- Update the page or bundle reference to that URL.
- Purge only the affected HTML or asset paths if stale references must be removed quickly.
- Check the origin, CDN, and browser-visible response independently.
- Record the change so the next normal build does not restore the broken reference.
What to double-check
Cache busting can fail at any layer between the origin and the browser. Inspect the complete public URL, including its query string, hostname, protocol, and path. A CDN may use a different cache key from the browser, and a reverse proxy may normalize or ignore query parameters according to its configuration.
- Response headers: Review
Cache-Control,ETag,Last-Modified, andAgewhere available. These help show whether the response is cacheable and whether it was served from an intermediary. - CDN status: Check cache-status headers or the provider's diagnostic information. Test from more than one location when edge behavior matters.
- HTML and manifest consistency: Verify that deployed HTML, JavaScript imports, CSS
url()references, and manifest entries all point to files from the same release. - Compression and content type: A new file should be returned with the expected MIME type and encoding. A cache hit for the wrong content type can look like a versioning failure.
- Service workers: A service worker can maintain its own cache and may serve an older asset even after the browser and CDN have the new response. Review its cache names, update logic, and activation behavior.
- Rollback compatibility: Keep old hashed assets available long enough for cached HTML and older application chunks to stop referencing them.
For a systematic investigation, compare the public response with the origin response and record the request URL and key headers. The guide How to Check if a Website Is Cached provides a useful testing framework. You can also use this cache-control headers guide to review policy choices for static files.
Common mistakes
- Changing only the source file: Editing
app.cssdoes not change its cache key. The deployed reference must change, or the object must be revalidated or purged. - Using a timestamp inconsistently: If HTML receives a new version but a CSS import still points to an old version, users can receive a mixed release.
- Purging everything by default: A full cache purge can increase origin load and remove useful cached content. Prefer versioned URLs and targeted invalidation.
- Deleting old hashed files immediately: Cached HTML, background tabs, or rolling deployments may still request them. Retain compatible files during the transition.
- Assuming query strings always work: Check CDN cache-key settings, origin routing, and application behavior before relying on them.
- Putting build metadata in the wrong place: A version comment inside a file does not change the URL and therefore does not reliably bust a browser or CDN cache.
- Ignoring imported assets: A new stylesheet may reference an old font, background image, or nested CSS file. Treat the asset graph—not just the top-level file—as part of the release.
When to revisit
Review this process before seasonal planning cycles, redesigns, migrations, and any change to your build, hosting, CDN, or deployment workflow. Revisit it immediately when you introduce a new bundler, image pipeline, service worker, WordPress optimization plugin, reverse proxy, or cache-key rule.
Before each release, use this short final checklist:
- Build assets and confirm that changed content produces changed URLs.
- Deploy new assets before the HTML or manifest that references them.
- Check cache-control policy and CDN cache-key behavior.
- Test a fresh URL, an old URL, and the page that loads both.
- Inspect browser, CDN, and origin responses if results disagree.
- Document any purge, rollback, or retention step required by the release.
A dependable cache-busting strategy should make ordinary deployments routine rather than dependent on clearing every cache. Measure the result with the cache hit ratio and CDN performance guide, and revisit the rules whenever your delivery architecture changes.