Service Worker Update Stuck — PWA Not Updating to Latest Version
About Service Worker Update Stuck
Fix Progressive Web App (PWA) stuck on an old version because the Service Worker update is waiting to activate or the cache is serving stale content. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: Service Workers update when the browser detects a byte-level change in the Service Worker script. New Service Workers enter a 'waiting' state until all tabs using the old version are closed. The waiting-to-activate behavior prevents breaking in-use tabs with a new Service Worker version. skipWaiting() in the Service Worker forces immediate activation (may break active pages). Cache-first strategies can serve stale content even after the Service Worker updates. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: User has not closed all tabs of the PWA, keeping the old Service Worker active. Service Worker uses cache-first strategy and the cache has not been updated with new content. skipWaiting() not called in the install event, leaving the new worker in waiting state. Browser caching the Service Worker file itself (set Cache-Control: no-cache on sw.js). Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Prompt users to reload: listen for 'controllerchange' event and show an 'Update Available' banner. Call skipWaiting() in the new Service Worker's install event to force immediate activation. Call clients.claim() in the activate event to take control of all open tabs immediately. Update cache in the activate event: delete old cache versions and populate the new cache. Set Cache-Control: no-cache, no-store on the Service Worker file to prevent HTTP caching of sw.js. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Browser Errors collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Why does the Service Worker not update immediately?
By design, Service Workers wait until all tabs using the old version are closed. This prevents breaking active pages that expect the old worker's behavior. Use skipWaiting() to override this, but test thoroughly for compatibility.
Overview
Fix Progressive Web App (PWA) stuck on an old version because the Service Worker update is waiting to activate or the cache is serving stale content.
Key Details
- Service Workers update when the browser detects a byte-level change in the Service Worker script
- New Service Workers enter a 'waiting' state until all tabs using the old version are closed
- The waiting-to-activate behavior prevents breaking in-use tabs with a new Service Worker version
- skipWaiting() in the Service Worker forces immediate activation (may break active pages)
- Cache-first strategies can serve stale content even after the Service Worker updates
Common Causes
- User has not closed all tabs of the PWA, keeping the old Service Worker active
- Service Worker uses cache-first strategy and the cache has not been updated with new content
- skipWaiting() not called in the install event, leaving the new worker in waiting state
- Browser caching the Service Worker file itself (set Cache-Control: no-cache on sw.js)
Steps
- 1Prompt users to reload: listen for 'controllerchange' event and show an 'Update Available' banner
- 2Call skipWaiting() in the new Service Worker's install event to force immediate activation
- 3Call clients.claim() in the activate event to take control of all open tabs immediately
- 4Update cache in the activate event: delete old cache versions and populate the new cache
- 5Set Cache-Control: no-cache, no-store on the Service Worker file to prevent HTTP caching of sw.js