Cached assets not detected by workbox
See original GitHub issueLibrary Affected: workbox-strategies, workbox-expiration
Browser & Platform: all browsers
Issue or Feature Request Description:
After warming up cache with:
await articleStrategy.handle({request: new Request(article)})
strategy is defined as:
const articleStrategy = new StaleWhileRevalidate({
cacheName: 'cache-articles',
plugins:[
new CacheableResponsePlugin({
headers: {
'X-Is-Single': 'true',
},
}),
new ExpirationPlugin({
maxAgeSeconds: 60 * 60 * 24 * 7,
maxEntries: 20,
}),
],
})
the router that handles requests with exact same strategy is unable to find the urls in cache despite the fact that Chrome DevTools show them as present. Additionally both caches.match()
and cache.match()
are able to find the request in cache. Workbox is not able to do so.
After navigating to the url that is expected to be cached and waiting for the response to be handled with the exact same strategy the request is now in cache and workbox sees it for further requests.
I also find it strange that this behaviour was found on our remote testing servers but not on local ones. I could suspect that headers could have something to do with it but then why would the strategy cache the exact same response correctly when navigating to the page.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Found a solution. Vary header was messing with this.
ignoreVary: true
fixes this.Yes I’m seeing this whenever articleStrategy is run. Here’s full code of my service worker. I’ll also try to setup a live reproduction for you soon.