NEW332455
Service worker soft update never hits the HTTP cache on macOS
https://bugs.webkit.org/show_bug.cgi?id=332455
Summary Service worker soft update never hits the HTTP cache on macOS
Gregory Mitchell
Reported 2026-11-19 13:54:42 PST

On macOS, WebKit sends an unconditional network request for the service worker script after every document navigation, even when the script is served with Cache-Control: max-age=86400 and the registration uses updateViaCache: 'all'.

The request is a full 200 each time. On Linux with a persistent profile the same page does not make this kind of request.

Steps to Reproduce

Serve a page that registers a service worker with:

navigator.serviceWorker.register('/sw.js', { updateViaCache: 'all' })
  • Serve /sw.js with Cache-Control: max-age=86400 and log every request that reaches the server.
  • Let the worker install and take control.
  • Navigate to a same-origin document, wait 1.5 seconds, and repeat several times. Also, open a new tab to the same origin.

Expected

Inside the script's freshness lifetime the soft update is answered from the cache, so the server sees no request for /sw.js.

Actual

The server sees one GET /sw.js about one second after each document navigation: 6 of 6 navigations and 3 of 3 new tabs on macOS in Playwright's WebKit with a persistent profile, and 4 requests for 3 navigations and one reload in Safari 26.5.2. The count is the same at script lifetimes of 2, 6 and 20 seconds and one day. Navigations under a second apart share one request, because the soft update timer is one second and ignores navigations while it runs. Linux with a persistent profile makes 0. An explicit registration.update() called from the page does hit the cache on macOS.

Additional Information

Read at WebKit main, eb96cf53cad2f39d67ffd557e91d7e6a91d5bcc4; Playwright's WebKit build may differ from it, so each claim is paired with the counts above. Page requests are keyed with a cache partition equal to the host (SecurityOrigin::domainForCachePartition). The soft update request is built without a partition (SWServer::createScriptRequest). The cache key includes the partition (NetworkCache::Cache::makeCacheKey), so the lookup for the script cannot match an entry stored under a partitioned key. The soft update loader never stores what it fetches (ServiceWorkerSoftUpdateLoader.cpp has no store call), so nothing can fill the unpartitioned key either.

Import Scripts

A worker whose main script is a small importScripts('<core URL>') shim, with the core at an immutable URL (Cache-Control: public, max-age=31536000, immutable), still gets the core re-fetched in full on every document navigation. Playwright WebKit 27.2 on macOS, persistent profile, five navigations at 1.5 s, two runs. The server saw one GET for the shim and one GET for the core per navigation, each core a 200 with the full 134,609-byte body (5 of 5 navigations, both runs). No conditional headers on any request.

Chromium 156 and Firefox 157 fetched the core once, with the install, and nothing after it in the same runs.

The core fetch during a soft update does not change the running worker unless the main script changes. When the core changed on the server with the main script byte-identical, WebKit kept running the old core for every navigation, even though it fetched the new content on each navigation. A changed core under an unchanged main script is not an update. Source reading is that the imports of a soft update use the same uncached path as the main script. The probe shows the behaviour, not the cause.

Attachments
Radar WebKit Bug Importer
Comment 1 2026-11-26 13:55:15 PST
Note You need to log in before you can comment on or make changes to this bug.