Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Old cached service worker serving outdated app: how to fix it

OPS-301Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A service worker is a JavaScript file that a browser installs for your site. It sits between the page and the network and can answer requests from a cache. Progressive web apps, some themes, some plugins and some frameworks add one without you noticing.

The problem starts when the worker keeps serving cached HTML, scripts or API responses from an older release. The browser checks for a new worker file, but the new one often waits until every tab using the old one is closed. Until then, the old worker keeps answering.

Why it costs you leads or sales

Returning visitors are often your warmest ones: people who saw an ad, left, and came back to buy. If they get the old version, they may see an expired offer, a form that posts to a retired endpoint, or a checkout script that no longer matches the server. Tracking tags you added or fixed in the latest deploy may be missing for them too.

It is hard to catch because you and your team usually test in a fresh or hard-refreshed browser. The bug only shows for people who already have the old worker installed.

How a stale service worker hides your fix
  1. Deploy new releaseServer now has the fixed site
  2. Returning visitor opens siteOld service worker is still active
  3. Worker serves cached filesOld HTML and scripts returned, network skipped
  4. Old form or offer shownRetired endpoint or expired price
  5. Lead or saleSubmission fails or is never made

The deploy succeeds on the server, but returning visitors never receive it.

How to check if your site has it

Check for an active service worker
  1. Open DevTools Application panel

    In Chrome or Edge, press F12 and open Application, then Service workers. If a worker is listed for your domain, your site uses one.

  2. Compare versions

    Load the site in a normal window that has visited before, and in a fresh Incognito window. If they differ (different text, form, banner), a worker or cache is serving old content.

  3. Look at the status

    A worker marked 'waiting to activate' means a new version is downloaded but the old one still controls the page.

  4. Inspect the cache

    Under Application, Cache storage, open each cache and check which HTML, JS and API URLs are stored.

  5. Check how the worker file is cached

    In the Network tab, find your service worker file (often sw.js) and read its Cache-Control header. A long max-age delays updates.

How to fix it

First decide whether you need a service worker at all. Most lead-generation sites and stores do not. If you do not need offline use or push notifications, remove it. If you do, make it update reliably.

Fix by platform
  1. Find what registers the worker

    Check plugins for PWA, offline or caching features (Plugins screen, then settings of any PWA or performance plugin). Search the theme for navigator.serviceWorker.register.

  2. Disable or update it

    Turn off the PWA or offline option, or update the plugin. Then purge the page cache and CDN cache.

  3. Ship a kill switch

    If visitors still have the old worker, serve the cleanup worker shown below at the same URL the old one used.

If you keep a worker, this pattern removes old caches and activates new versions straight away.

sw.js: versioned cache, fast activation, network-first pagesjavascript
const VERSION = 'v2024-06-01';
const CACHE = 'site-' + VERSION;

self.addEventListener('install', (event) => {
  self.skipWaiting();
  event.waitUntil(caches.open(CACHE));
});

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys()
      .then((keys) => Promise.all(
        keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))
      ))
      .then(() => self.clients.claim())
  );
});

self.addEventListener('fetch', (event) => {
  if (event.request.mode === 'navigate') {
    event.respondWith(
      fetch(event.request).catch(() => caches.match(event.request))
    );
  }
});

If you want to remove the worker entirely, replace the old worker file (same URL) with this self-destructing one. Visitors' browsers fetch it, clear the caches and unregister.

sw.js: kill switch that removes the worker and its cachesjavascript
self.addEventListener('install', () => self.skipWaiting());

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys()
      .then((keys) => Promise.all(keys.map((k) => caches.delete(k))))
      .then(() => self.registration.unregister())
      .then(() => self.clients.matchAll())
      .then((clients) => clients.forEach((c) => c.navigate(c.url)))
  );
});
Before and after the fix

Stale worker

  • Returning visitors see last release
  • New worker waits for tabs to close
  • sw.js cached for a long time
  • Only fresh browsers show the fix

Updating worker or none

  • New release reaches returning visitors on next load
  • Old caches deleted on activate
  • sw.js served with no-cache
  • Pages fetched network-first

How to confirm it's fixed

Confirmation checklist
  • In a profile that still has the old worker, load the site once or twice and confirm the new version appears.
  • In DevTools, Application, Service workers shows the new worker as activated, or no worker at all if you removed it.
  • Cache storage contains only the current version name.
  • The sw.js response has Cache-Control: no-cache (or a short max-age).
  • Your form submits and the test lead arrives in your inbox or CRM.
  • Tracking hits for the page appear in the Network tab or your platform's debug view.

How to prevent it happening again

Prevention checklist
  • Only use a service worker if you need offline use or push notifications.
  • Change the cache version on every release, ideally automatically in your build.
  • Never cache HTML, forms or checkout API calls cache-first.
  • Serve the worker file with no-cache headers, and keep its URL stable.
  • Add a returning-visitor test (old profile, new release) to your release checklist.
  • Review plugins, apps and tag manager tags that may add a worker.
Example: how a stale worker plays out after a release
  1. Day 0

    You fix a broken form and deploy. Fresh browsers work.

  2. Day 1

    Returning visitors still get the cached old page and form.

  3. Day 3

    Leads from returning visitors still look low, but your own tests pass.

  4. Day 4

    You find the worker, ship the kill switch or fixed worker.

  5. Day 5

    Returning visitors get the current version on next load.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. A robot visitor runs your real journeys on a schedule, and checks each step, the tracking hits and whether test leads arrive. If a stale worker or cache breaks a step, such as a form that no longer submits or a tag that no longer fires, the failure is re-checked from a second region and you get one alert with a screenshot and a likely cause.

What it does not do is reproduce a returning visitor who already holds an old service worker. The robot starts from a clean visit, so it sees the current release, not the stale copy your past visitors may still get. FunnelGuard does not inspect which service workers or caches are installed in real visitors' browsers.

Cover the rest by hand: after each release, open the site in a normal browser profile that visited before, follow the checks above, and confirm the new version loads. FunnelGuard's Free plan (1 site, 2 journeys, daily checks, no card) is enough to watch your main form and catch the cases it can see.

Questions people ask

Why is my website showing an old version after I updated it?

If it only happens in browsers that visited before, a service worker or other cache is probably serving the old files. Check DevTools, Application, Service workers, and compare with an Incognito window. If the versions differ, update or remove the worker.

How do I unregister a service worker?

For your own browser, open DevTools, Application, Service workers and click Unregister. For all visitors, serve a replacement worker at the same URL that deletes caches and calls registration.unregister(), and keep it live for a few weeks.

Why does a hard refresh fix the site but not for my visitors?

A hard refresh bypasses the service worker and cache for your own session. Your visitors will not do that, so they keep getting the cached copy until the worker updates or is removed.

How do I make a service worker update immediately?

Change the worker file (for example a new version constant), call self.skipWaiting() on install and clients.claim() on activate, and delete old caches during activate. Also make sure the worker file is not cached for long.

Do I need a service worker on a lead generation site?

Usually not. A service worker is useful for offline use and push notifications. For forms, landing pages and checkouts, it mostly adds the risk of serving outdated pages, so removing it is often the safest choice.

Can a service worker break tracking or forms?

Yes. If it serves an old page or script, the form may post to an outdated endpoint and tags added in later releases may be missing. Returning visitors are affected while new visitors look fine.

Can FunnelGuard detect a stale service worker?

Only partly. It catches failures such as a broken form or missing tracking hit in a clean visit, but it does not reproduce a returning visitor with an old worker installed. Test that case by hand after each release.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

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.