Skip to content
FunnelGuard

Fix guide by FunnelsGuard

JS bundle 404 after deploy: stale cached HTML and old hashes

PRF-122High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Modern build tools add a hash to each file name, such as app.3f9a1c.js. The hash changes whenever the code changes. This lets browsers cache files for a long time safely.

The problem starts when you deploy a new version. The new build creates app.7b2e90.js and often removes the old file. But some visitors, a CDN or a page cache still hold the old HTML, which asks for app.3f9a1c.js. That file is gone, so the server returns 404 Not Found.

How a stale page breaks after a deploy
  1. DeployNew build replaces old hashed files
  2. Cached HTML servedCDN or cache still holds the old page
  3. Old bundle requestedapp.3f9a1c.js returns 404
  4. Form and buttonsNo JavaScript, no handlers
  5. Tracking and leadTags and submissions never happen

The cached HTML points to a file the new release removed.

Why it costs you leads or sales

The page still loads, so nothing looks wrong at a glance. But if the missing file holds your form logic, checkout code, chat widget or tag setup, those parts stop working. Visitors click and nothing happens.

Ad traffic makes it worse. You keep paying for clicks that land on a page that cannot convert. Because analytics scripts may also fail, the lost conversions may not even show in your reports.

How the problem unfolds (example)
  1. 10:00

    You deploy a new release. Old JS files are removed.

  2. 10:01

    Your CDN keeps serving the HTML it cached earlier.

  3. 10:02

    Visitors load the page; the old script URL returns 404.

  4. Next day

    Leads are down, but no one has seen an error.

  5. Later

    Cache is purged or expires and the page works again.

Form submissions around a bad deployExample numbers
Form submissions around a bad deploy (example)Before deploy: 40 submissions per day; Day of deploy: 14 submissions per day; Day after: 22 submissions per day; After cache purge: 41 submissions per day0163140142241Before deployDay of deployDay afterAfter cache purgesubmissions per day

Example: illustrative numbers showing how a stale-cache 404 can quietly cut submissions until the cache clears.

How to check if your site has it

Check for a 404 on a script file
  1. Open the page in a private window

    Use the exact URL your ads or emails send people to.

  2. Open DevTools and the Network tab

    Press F12, open Network, tick Disable cache off, and reload. Filter by JS.

  3. Look for red 404 rows

    A failed .js file with a hash in its name is the sign of this issue. The Console tab will also show 'Failed to load resource: 404'.

  4. Compare with the live HTML

    Right-click, View page source, and note the script URLs. Then open one directly. If it returns 404, the HTML is stale.

  5. Check the cache headers on the HTML

    Run the command below and look at Cache-Control, Age and any CDN cache status header.

Check HTML and script statusbash
curl -sI https://example.com/landing/ | grep -iE 'cache-control|age|etag|x-cache|cf-cache-status'
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/assets/app.3f9a1c.js

How to fix it

The goal is simple: HTML and the files it references must stay in step. Either keep old files around for a while, or make sure HTML is refreshed right after each deploy.

Fix the stale reference
  1. Purge the HTML cache now

    Clear your CDN, page cache and server cache so new HTML with new hashes is served.

  2. Keep old assets after a deploy

    Do not delete the previous release's hashed files straight away. Keep them for several days so cached pages still work.

  3. Do not cache HTML for long

    Use a short or revalidating Cache-Control on HTML, and a long immutable cache only on hashed assets.

  4. Purge cache as part of the deploy

    Add a cache purge step at the end of your deploy pipeline.

Nginx: short HTML cache, long cache for hashed filesnginx
location / {
  add_header Cache-Control "no-cache";
}

location /assets/ {
  add_header Cache-Control "public, max-age=31536000, immutable";
}
Where to look on your platform
  1. Purge all caches

    Clear your caching plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache and similar) and any host or CDN cache.

  2. Regenerate combined files

    If a plugin minifies or combines JS, clear its generated files so the HTML points to current ones.

  3. Exclude key pages from page cache if needed

    Landing pages, checkout and forms can be set to bypass cache in your caching plugin settings.

Deploy setup

Before

  • Old JS files deleted on every deploy
  • HTML cached for hours or days
  • No cache purge after release
  • Failures found by customers

After

  • Previous build's files kept for several days
  • HTML revalidated or cached briefly
  • Cache purged at the end of each deploy
  • Key pages checked after every release

How to confirm it's fixed

Confirmation checklist
  • Load the page in a private window and see no red 404 rows in the Network tab
  • Every script URL in the page source returns 200
  • The Console shows no 'Failed to load resource' errors
  • The form submits and the thank-you page or message appears
  • Your ad and analytics tags fire (check with Tag Assistant or the Network tab)
  • Test from a second network or region

How to prevent it happening again

Deploy habits that avoid stale hashes
  • Keep at least the last one or two releases' assets available
  • Serve HTML with no-cache or a short max-age
  • Serve hashed assets with a long immutable cache
  • Purge page and CDN caches automatically after each deploy
  • Avoid hard-coded hashed file names in templates or tag managers
  • Run a quick test of your main forms and checkout after every release

How FunnelGuard handles this

FunnelGuard detects this issue. A robot visitor loads your funnel pages on a schedule and records any script that fails to load. A hashed JS file returning 404 shows up as a failed script in the check.

If a check fails, FunnelGuard re-checks from a second region before sending one alert by email, Slack, Teams, WhatsApp, webhook or PagerDuty. The alert includes a screenshot and a likely cause. It checks the pages and journeys you set up, so it will not see every visitor who holds an old cached page. The Free plan covers 1 site and 2 journeys with daily checks and no card needed.

A script 404 after deploy

The page loads, but the missing bundle stops everything that depends on it.

Questions people ask

Why is my JS file returning 404 after a deploy?

Your new release probably removed the old hashed file, but cached HTML still asks for it. The cache can be in a CDN, a page cache plugin, a server or the visitor's browser. Purge the cache and keep old assets for a few days.

How do I fix a stale cached HTML page pointing to old JavaScript files?

Purge your CDN and page caches, then set HTML to no-cache or a short max-age. Keep hashed assets on a long immutable cache. Also keep the previous build's files available after each deploy.

Should I cache HTML and JavaScript for the same length of time?

No. Hashed JS and CSS can be cached for a year because their names change with their content. HTML should be revalidated or cached briefly, because it holds the links to the current hashed files.

Why does my site work for me but not for some visitors after a deploy?

Those visitors may hold older cached HTML, or hit a CDN edge that has not refreshed. You loaded the new page, so you see the new file names. Test in a private window and from other networks.

Will a JS 404 stop my form and tracking from working?

Yes, if the missing file contains the form logic or tag code. The page still looks normal, but buttons do nothing and conversion tags may never send. That is why this issue can cost leads without obvious errors.

How can I tell which script is returning 404?

Open DevTools, go to the Network tab, reload and filter by JS. Failed files show a red 404 status. The Console also lists 'Failed to load resource' with the file URL.

Can FunnelGuard detect a JS bundle 404?

Yes. Its scheduled checks load your funnel pages and flag a script that failed to load. It re-checks from a second region and then sends one alert with a screenshot and a likely cause.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: failed script.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.