TapCub is live — analytics, insights and live chat, free on one platform
Glossary

Cache busting: how to make browsers load new files

Cache busting changes a file's URL when its content changes. Content hashes vs query strings, how it pairs with immutable, why visitors still see old assets and a worked release example.

Xu An Reviewed by Lucas Hayes Also called cache buster Last updated Dec 3, 2026 Glossary

Quick answer

Cache busting means changing a file's URL when its content changes, usually with a content hash in the file name or a version query string, so browsers and CDNs fetch the new version instead of reusing a cached copy. It is what makes very long cache lifetimes safe.

What is cache busting?

Cache busting is the practice of changing a file's URL when its content changes, so that browsers and CDNs fetch the new version instead of reusing the copy they already hold. The usual tools are a hash of the content in the file name, a version number in the path, or a query string such as ?v=42.

It exists because HTTP caching is keyed by address. Under RFC 9111 a cache stores a response against, at minimum, the request method and the target URI. While a stored copy is fresh, the cache may answer from it without asking the server. If you replace styles.css on the server but keep the name, a visitor holding a fresh copy never learns about it. There is no message you can send to every browser that says "drop that file". A new URL is the message: it is a key that no cache has seen.

Content-hash filenames vs query strings vs path versions

MethodExampleWhat changes the URLStrengthRisk
Content hash in the file nameapp.3f9a1c.jsThe file's own contentOnly changed files get new URLsNeeds a build step that rewrites references
Version folder in the path/v42/app.jsThe release numberSimple, whole release stays consistentEvery file gets a new URL on every release
Date or sequence in the namelogo_2.pngA manual renameWorks without toolingEasy to forget
Query string with a versionapp.js?v=42The query valueNo renaming of filesSome cache settings ignore the query string
Query string with a timestampapp.js?t=1764720000Every request or buildNever staleIf set per request, nothing is ever reused

The content hash is the most precise of these, because the name is derived from the bytes. Build tools do it for you; webpack, for instance, offers a [contenthash] placeholder that changes only when the content of an asset changes. Amazon's CloudFront guide likewise recommends version identifiers in file or folder names, so that you do not have to wait for objects to expire or pay for invalidations.

Query strings work when every cache on the way includes them in the key. That is a setting, not a guarantee. Cloudflare's default caching level delivers a different resource each time the query string changes, but its "Ignore Query String" level serves the same cached static file whatever follows the ?. CloudFront lets you choose whether query parameters are part of the cache key. Check your own configuration before you rely on ?v=.

How cache busting works with Cache-Control immutable

Cache busting is what makes a very long cache lifetime safe. For URLs that carry a fingerprint and never change content, web.dev's guidance is Cache-Control: max-age=31536000, one year. You can add immutable:

Cache-Control: public, max-age=31536000, immutable

RFC 8246 defines immutable as a promise that the server will not update that response during its freshness lifetime. Clients should then skip the conditional request they would otherwise send, for example when a visitor reloads, unless the visitor forces a reload. web.dev notes that some browsers ignore it.

The promise has one condition: you never publish different bytes under the same URL. Break it once and there is nothing to undo it with, because the browsers that hold the old copy have been told not to ask.

The HTML page is the other half. It is the file that lists the hashed names, and its own address does not change. Serve it with Cache-Control: no-cache, which allows storing it but requires checking with the server before each reuse. Vite's documentation makes the same point for single-page apps: without no-cache on the HTML, old assets are still referenced. The Cache-Control header guide lists a value for each file type.

Worked example: one release, five files

Sample data: a returning visitor has everything cached. A release changes only the application script. Sizes are transfer sizes.

FileSizeHashed names: re-downloaded?One version number for all: re-downloaded?
index.html30 KBYes (checked every time and changed)Yes
Third-party library bundle400 KBNoYes
Application script120 KBYesYes
Stylesheet80 KBNoYes
Fonts60 KBNoYes
Total re-downloaded150 KB690 KB

With one release number applied to every URL, the visitor fetches 30 + 400 + 120 + 80 + 60 = 690 KB. With per-file hashes it is 30 + 120 = 150 KB, which is 540 KB less, or 78%. For 10,000 returning visitors per release that is 540 KB × 10,000 = 5.4 GB (counting 1 GB as 1,000,000 KB). At 20 releases a month, the difference reaches 108 GB, assuming the same visitors return after each release.

Hashing only pays off if unchanged files keep the same name. Bundles that mix library code with your own code get a new hash on every edit, so put stable third-party code in its own bundle.

Why do visitors still see old files?

When a release is out and someone still sees the old version, one of these is usually true.

SymptomLikely causeWhat to check or change
Old page, old assetsThe HTML itself has a long lifetime, at the browser or the CDNUse no-cache for HTML; purge the CDN copy once
New HTML, old file contentThe file name did not change and the old copy is still freshPut a hash in the name; a long lifetime on a fixed name cannot be recalled
?v= changed, CDN serves the old fileThe cache key ignores the query stringChange the CDN setting or move the version into the name
Some visitors onlyThe file has no Cache-Control, so browsers guessed a lifetimeSend an explicit header
Works in a private window onlyA service worker is answering from its own cacheVersion the worker's cache; a new worker waits until old tabs close
Error on navigation in an old tabThe running app asks for a chunk that the deployment deletedKeep previous builds for a while, or catch the error and reload
Broken only during a rolloutNew HTML reaches a server that does not have the new file yetUpload assets before switching the HTML

The deleted-chunk case is easy to miss in testing, because it only affects people who opened the site before the release. Vite's documentation describes exactly this and emits a vite:preloadError event that an app can handle, for example by refreshing the page.

The service worker case follows from its lifecycle. According to web.dev, an updated worker installs next to the old one and waits until the old one controls no pages, so a visitor who keeps a tab open can stay on the old version after you have shipped.

How to find out which cache is serving the old file

  1. Read the HTML the visitor gets. curl -sI https://example.com/ shows its cache-control and age. Then view the source and note the asset names it references.
  2. Request the asset directly. curl -sI https://example.com/assets/app.3f9a1c.js shows the headers and, on most CDNs, a cache status header.
  3. Compare with the origin. If you can reach the origin directly, the difference between the two answers tells you whether the CDN holds the old copy.
  4. Open the browser's Network panel. A response from memory or disk cache means the browser made no request at all. A response served by a service worker is labeled as such.
  5. Test with the cache disabled, then enabled. If the problem appears only with the cache on, it is a caching rule and not a faulty build.

Cache busting vs purging vs revalidation

Cache bustingCDN purgeRevalidation
What happensThe file gets a new URLCopies are removed from the CDNThe cache asks whether its copy is still current
Reaches browser cachesYes, through the new referenceNoOnly when the browser decides to ask
CostA build stepAn operation per release, possible origin spikeOne request per check, often answered with 304
Best forScripts, styles, fonts, versioned imagesHTML and files whose URL must stay fixedHTML and API responses

Purging cannot fix a year-long lifetime already sitting in a visitor's browser. The reverse also holds: busting does nothing for a URL you cannot change, such as the home page. Most sites need all three, each for its own kind of file. A purge also empties the edge, so the cache hit rate drops until it refills; CDN cache explains how to read that.

Common cache busting mistakes

  • Long lifetime first, hashing later. Fix the file names before you raise max-age.
  • Random query strings on every request. It looks like a fix for staleness and quietly turns caching off.
  • Deleting old builds on deploy. Visitors with an open tab or a cached page still ask for them.
  • Hashing the HTML URL. People and search engines need stable page addresses; version the assets instead.

Cache busting releases in TapCub

Suppose you switch from one release number to per-file hashes. TapCub does not set your headers, rename files or purge a CDN; it measures what happens in visitors' browsers.

  1. Mark the release. In Configuration › Annotations, add an entry of type Release so the date appears on the trend charts.
  2. Watch for errors from old tabs. With data-errors="true" in the snippet, Monitoring › Errors groups JavaScript errors and unhandled promise rejections, with the pages and sessions involved. A failed dynamic import that nothing catches shows up as a rejection. A missing file requested by a plain script tag is easier to find as a 404 in server logs.
  3. Compare load times. In Monitoring › Performance, set the range to two weeks before and then two weeks after, and read P75 largest contentful paint and the loading breakdown. The page has no previous-period comparison, so note the first set of values.
  4. Check the slowest pages. If a page stays slow, confirm that its assets carry hashed names and a long lifetime.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Xu An

Customer Experience Consultant

Writes about live chat, visitor conversations, and self-service, sharing practical ways to make customer communication clearer and more effective.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

Is a query string enough for cache busting?

It works when every cache on the path includes the query string in its key. Some settings do not: Cloudflare's Ignore Query String level serves one cached static file for any query. A hash in the file name avoids the question, because the path itself changes.

Does a hard refresh bust the cache for my visitors?

No. A forced reload only affects the browser where you press it. Other visitors keep their fresh copies until those expire. To reach everyone, publish the file under a new URL and make sure the HTML that references it is revalidated.

Should HTML files be cache busted too?

Not by renaming them: page addresses need to stay stable for visitors, links and search engines. Serve HTML with Cache-Control: no-cache so it is checked before reuse, and let it point at hashed asset names that change with each release.

Why do users get chunk load errors after a deploy?

Their open page was built before the release and asks for a code chunk by its old name. If the deployment deleted that file, the request fails. Keep previous builds available for a while, or catch the load error and reload the page.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics