- From: Brian Cardarella <notifications@github.com>
- Date: Thu, 05 Nov 2026 12:35:45 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/issues/1853@github.com>
bcardarella created an issue (w3c/ServiceWorker#1853)
In Handle Fetch (https://w3c.github.io/ServiceWorker/#handle-fetch), step 13.3.3.7 walks the storage key's name to cache map for a "cache" router source:
> 2. Let requestResponses be the result of running Query Cache with request, a new CacheQueryOptions, and cache.
> 3. If requestResponses is an empty list, return timingInfo.
Returning there sends the request to the network at the first cache with no match, even when a later cache has a response. With `source: {cacheName}` only one cache is queried (step 7.1), so this affects `source: "cache"` only.
Implementations search every cache, as `caches.match()` does:
- Chromium: ServiceWorkerCacheStorageMatcher::Run calls Cache Storage's Match with MultiCacheQueryOptions and no cache name, which is CacheStorage::MatchAllCaches: every cache in order, the first match wins.
https://source.chromium.org/chromium/chromium/src/+/main:content/browser/service_worker/service_worker_cache_storage_matcher.cc
https://source.chromium.org/chromium/chromium/src/+/main:content/browser/cache_storage/cache_storage.cc (MatchAllCachesImpl, MatchAllCachesDidMatchAll)
- WebKit (Safari 27): CacheStorageManager::query with an empty name calls queryCaches, which moves to the next cache when one has no match.
https://github.com/WebKit/WebKit/blob/main/Source/WebKit/NetworkProcess/storage/CacheStorageManager.cpp
- Gecko does not ship addRoutes (https://bugzil.la/1855580).
#1797 also describes "cache" as matching against all caches.
Scenario, in the install handler:
```js
await (await caches.open('a')).put('/other', new Response('other'));
await (await caches.open('b')).put('/data', new Response('from cache'));
event.addRoutes({condition: {urlPattern: '/data'}, source: 'cache'});
```
A controlled page's `fetch('/data')`: by the spec text, cache "a" has no match, so the request goes to the network. Chrome and Safari answer "from cache" from cache "b".
This shows up through leftover state: WPT's static-router tests use one cache, "v1", and fail in an engine that follows the text when an earlier test in the same browser session left another cache behind (resource-timing-cross-origin-server-timing.https.html leaves "test-cache").
Suggested change: step 13.3.3.7.3 becomes "If requestResponses is an empty list, continue." The existing step 13.3.3.8 ("Return timingInfo") then covers the case where no cache matches.
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1853
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/ServiceWorker/issues/1853@github.com>
Received on Thursday, 5 November 2026 20:35:49 UTC