< Back

How To Fix All Your PWA Issues Once And For All

No more stuck service workers, stale content, or broken updates

calendar

Nov 1, 2026

Header for posting How To Fix All Your PWA Issues Once And For All
Photo by Francis Ledger on Unsplash

Talk to developers about PWAs, and you’ll quickly hear about service worker hell: the notion that service workers are hard to control and impossible to understand.

Updates that refuse to appear, caches that seem to have a mind of their own, and users who apparently need to reinstall an app just to see a new button.

To some developers, service workers seem less like a web API and more like some kind of voodoo. You deploy a new version, sacrifice a few browser tabs, clear every cache you can find, and hope the browser gods will finally bless your users with the latest version of your app.

And when all else fails, there’s always skipWaiting() and clients.claim(), the magical spells that supposedly fix everything.

Except sometimes they make things worse.

But service workers aren’t magic, and they’re not haunted either. They actually have a well-defined lifecycle, and most of the mysterious update problems have perfectly logical explanations.

So let’s put away the candles, stop blaming the browser, and look at what actually goes wrong when PWAs update, why cache mismatches happen, and how to prevent them without resorting to ritual cache-clearing.

What are the issues developers run into?

Before we descend into the dark depths of this “service worker hell”, let’s first look at the most common issues developers run into with PWAs:

The good news is that these issues are perfectly solvable, without any sorcery, but with careful coordination and a solid understanding of the service worker lifecycle and caching mechanism.

Let’s dive in.

How service workers really work

Let’s start from a PWA that’s first opened in a browser.

It doesn’t have an active service worker yet, so the service worker will be newly installed for the first time and then, if everything goes right, immediately activated.

After that, the browser will check if there is a new service worker:

When service workers update

A new service worker means any changes to the service worker script or scripts that the service worker imports through importScripts() or static module imports.

Browsers do a byte-for-byte comparison of service worker scripts, so if you only change a single character in the service worker script, the browser will consider it new and will attempt to install it.

So making changes in any other files in your PWA (HTML, JavaScript, CSS, assets, etc.) will not trigger a service worker update.

If there is a change in the service worker script and you deploy it, it will be detected by the browser as new, and when users navigate to any other page in your PWA, the new service worker will be installed.

How service workers update

After a new service worker has been installed, it’s not activated immediately. The service worker lifecycle is deliberately conservative to avoid breaking running applications.

Instead, it enters the waiting state and stays there until the currently active service worker no longer serves any clients (PWAs, tabs, windows). This means you’ll need to close all clients and then reopen one, or navigate away from all clients and then navigate back in one client for the waiting service worker to be activated. This is when users will get the new version of your PWA.

New service worker in the “installing” state in Chrome DevTools
New service worker in the “installing” state in Chrome DevTools
New service worker in the “waiting” state in Chrome DevTools
New service worker in the “waiting” state in Chrome DevTools

When service workers don’t update

When your PWA doesn’t receive any service worker updates, it usually means:

How to fix service workers that don’t update

First, check if there are any changes in the service worker script. If there aren’t, the browser will not consider the service worker updated and won’t install it. A best practice is to add a version number to your service worker and update this whenever you deploy a new version of your app.

This makes sure the service worker script is changed, and it will be considered updated by the browser, even if you only made changes to other files in your PWA. You can use this version number also to version your cache, which is another best practice as I will explain later.

const SW_VERSION = 123;

const cacheName = `pwa_cache_${SW_VERSION}`;
self.addEventListener('fetch', event => {
event.respondWith(
caches.open(cacheName).then(cache =>
cache.match(event.request)
)
);
});

If your PWA is a long-running application that rarely reloads and users stay on one page, the browser will not detect any updated service workers.

A solution is to actively check for service worker updates, and you can do so by calling registration.update() at appropriate moments, for example when the PWA returns to the foreground:

document.addEventListener('visibilitychange', async () => {
if(document.visibilityState === 'visible' && navigator.serviceWorker.controller) {
const registation = await navigator.serviceWorker.getRegistration();
registration.update();
}
});

Calling registration.update() will make the browser check for a new service worker and, when found, the browser will attempt to install it.

A last issue can be that your CDN serves a cached copy of the service worker. When browsers check for a new service worker, they already bypass the browser’s HTTP cache, but when fetching the service worker from the network, a CDN can still serve a stale version from its cache, so you need to make sure a fresh copy is always served when it was changed.

You can change the behavior of bypassing the HTTP cache with the updateViaCacheregistration option that is passed to register():

navigator.serviceWorker
.register(”/service-worker.js”, {
updateViaCache: “none”
})

It can take the following values:

When service workers don’t install

When a (new) service worker doesn’t install, it usually means:

How to fix service workers that don’t install

Obviously, you need to make sure there are no JavaScript (syntax) errors in the service worker script. If there are, the service worker will not install, and the currently active service worker will remain active to make sure the PWA doesn’t break.

Service workers can also import other scripts, and if any import fails, the script will throw an error, and the service worker won’t be installed, so always make sure the imports resolve and don’t throw any errors.

The install event handler of the service worker is the place where the service worker cache is populated, and often PWAs use the cache.addAll() convenience method to cache a list of resources:

self.addEventListener("install", (event) => {
event.waitUntil(
caches
.open("v1")
.then((cache) =>
cache.addAll([
"/",
"/index.html",
"/style.css",
"/app.js",
]),
),
);
});

Note that this method is atomic, so when any resource in the list fails to cache, no resource from the array that was passed to it will be cached, and the returned Promise will be rejected.

This is useful for precaching essential resources that the PWA needs to work offline. If any of the resources couldn’t be fetched, installation will fail instead of succeed with an incomplete cache.

To keep a service worker in the installing state while caching resources, the code inside the handler for the install event is wrapped in a Promise that is passed to installEvent.waitUntil(). If that Promise rejects for any other reason, the service won’t be installed either.

So always make sure your service worker is free of errors, make caching failures observable, and validate any resources to be cached can be fetched.

When service workers are stuck in the waiting state

After a new service worker is successfully installed, it enters the waiting state, and it stays there until the currently active service worker no longer serves any clients.

This is to make sure a new service worker won’t break the running PWA because it can also bring changes to existing files or even delete them while they may still be needed by the current version of the PWA.

If the waiting service worker doesn’t activate when you close and reopen the PWA, browser tab, or window, it usually means:

How to fix service workers that are stuck in the waiting state

In the Application tab of Chrome DevTools, you can check the number of clients that the PWA serves in the Service workers section:

Chrome DevTools showing a PWA that serves two clients
Chrome DevTools showing a PWA that serves two clients

You need to make sure that all clients are closed or navigated away from before the service worker can transition from the waiting state to the active state.

The problem with skipWaiting() and clients.claim()

When a service worker is in the waiting state, you can force it into the active state by calling skipWaiting(), which will activate the new service worker and discard the active one.

This doesn’t necessarily mean the service worker will control all running clients, and you can call clients.claim() after that, which will make the new service worker control all previously uncontrolled clients as well.

While it’s, unfortunately, common practice to call these methods in the event handlers for the install and activate events, you need to be very careful with this as it can break your running PWA, as I will explain in the next section.

When the new PWA breaks the previous one

Let’s say you have a PWA v1 with a script app.js that is served from the service worker cache and that dynamically imports module1.js. The new version of the PWA (v2) changes module1.js or even deletes it.

If PWA v2 calls skipWaiting(), it means that the new service worker will be activated for both PWA v1 and PWA v2.

If PWA v1 is not reloaded and its script app.js dynamically imports module1.js, it may get the new version, which may contain code that is not compatible with PWA v1 and break it.

Even worse, when module1.js was deleted by PWA v2, PWA v1 can no longer import module1.js.

Therefore, you should be very careful with calling skipWaiting() and clients.claim(), as this may break existing PWAs that have not yet been reloaded.

How to fix a new PWA that breaks the previous one

Be very careful to call skipWaiting() and clients.claim() unconditionally. If you must do so, only do this when the service worker serves only one client, and make sure it reloads after that.

I created a basic service worker that calls skipWaiting() when a new service worker is waiting and the current service worker only serves one client. It does so right before a page is reloaded, so an added benefit is that the new service worker will then be activated when users navigate to another page or reload the current one, without having to close and reopen the app or navigate away from it.

When the new PWA serves stale content

When the new version of your PWA serves stale content from a previous version, it usually means:

How to fix a new PWA that serves stale content

Always use cache versioning. This couples a cache version with a service worker version and enables it to safely populate that new cache while the currently running PWA uses its own cache.

This also means you should never use caches.match(), as this searches across caches, which means a new PWA could accidentally serve incompatible content from an old cache or the current PWA could accidentally serve incompatible content from a new cache.

Version the cache name with the same version as the service worker and only serve content from that specific cache:

const SW_VERSION = 123;

const cacheName = `pwa_cache_${SW_VERSION}`;
self.addEventListener('fetch', event => {
event.respondWith(
caches.open(cacheName).then(cache =>
cache.match(event.request)
)
);
});

If a service worker cache is populated and resources are served by a CDN, you also need to make sure that CDN serves fresh content. Otherwise, stale content may end up in the service worker cache.

When a PWA no longer works offline after an update

So you updated your PWA to a new version, and now it no longer works offline.

This usually means:

How to fix a PWA that no longer works offline after an update

First of all, you always need to make sure that all routes in your app return an HTML page.

For a multi-page app, this means all pages should be cached, and for a single-page app, this means the app shell, usually index.html is cached. Often, a PWA caches assets like JavaScript, CSS, and images, but it doesn’t cache all routes that should return HTML.

Often, the home route “/” isn’t cached, so when you take your device offline and try to open the PWA, it will try to fetch the route “/” (index route) and shows you the default browser offline page. Therefore, you need to cache all routes (pages) of your app.

When the new version uses assets that weren’t cached

Suppose the current version of your PWA precaches this:

const ASSETS = [
‘/’,
‘/app.js’,
‘/styles.css’
];

Now the new version of your PWA introduces a new dependency:

<script src=”/app.js”></script>
<script src=”/charts.js”></script>

But if the new service worker only precaches:

const ASSETS = [
‘/’,
‘/app.js’,
‘/styles.css’
];

then charts.js won’t be available.

You can solve this by always making sure that the service worker caches all assets that are needed to work offline, for example, from your build output so the list is always up to date.

When an old version of the PWA still uses a cache that was deleted

When a new service worker activates, it typically deletes any old caches because they are no longer needed.

But if your PWA calls skipWaiting(), the following can happen:

  1. Version 1 is open and controlled by service worker v1.
  2. Service worker v2 installs and calls skipWaiting()
  3. Service worker v2 activates and deletes app-v1.
  4. The existing page is still running version 1 JavaScript.
  5. The user goes offline and requests a resource that was only available in app-v1.

This is another example of why you need to be very careful with calling skipWaiting() as in this example, it breaks the offline functionality of existing PWAs.

When the new service worker uses the wrong cache

I already mentioned how you should avoid caches.match() and always open a versioned cache that’s tied to the service worker version. You also need to make sure that the service worker opens the correct cache.

So if your PWA updates the name of the cache:

const CACHE_NAME = ‘app-v2’;

but the service worker still uses the old one:

self.addEventListener(’fetch’, event => {
event.respondWith(
caches.open(’app-v1’).then(cache =>
cache.match(event.request)
)
);
});

the PWA may fail to work offline because cache app-v1 most likely was deleted.

Always make sure the service worker uses the correct, versioned cache.

When the new service worker changed its caching strategy

If you want your PWA to work offline, you need to make sure all needed assets and routes to work offline are available from the cache.

If the caching strategy of some asset was changed to be always served from the network without a cache fallback, your PWA will break when offline. Carefully check if all assets and routes are available while offline after each update.

Service workers are not voodoo

Service workers can appear to be daunting and complex beasts. But a clear understanding of their lifecycle usually points you right at the solution for your issues.

I hope this article made a couple of things clearer.

If you still run into issues that you can’t figure out, don’t hesitate to contact me.


Join my email list Modern Web Weekly, for a weekly update on Progressive Web Apps (PWA), Web Components and new features of the modern web platform, tested and explained in plain English.