Error Codes Wiki

Service Worker Update Stuck — PWA Not Updating to Latest Version

Warninggeneral

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

  1. 1Prompt users to reload: listen for 'controllerchange' event and show an 'Update Available' banner
  2. 2Call skipWaiting() in the new Service Worker's install event to force immediate activation
  3. 3Call clients.claim() in the activate event to take control of all open tabs immediately
  4. 4Update cache in the activate event: delete old cache versions and populate the new cache
  5. 5Set Cache-Control: no-cache, no-store on the Service Worker file to prevent HTTP caching of sw.js

Tags

service-workerpwaupdatecacheskipWaiting

Related Items

More in General

Frequently Asked Questions

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.