Open numberknot opened 7 years ago
Thanks for reporting this. Some more information would be appreciated to get to the bottom of it.
If you can reproduce this behavior on a publicly deployed site, can you provide the URL?
If you don't have it deployed anywhere, can you provide your sw-toolbox
configuration, as well as a screenshot of both the Cache Storage and IndexedDB panels in the Applications tab of Chrome DevTools? Any log messages in the JS console would be useful as well.
Friendly ping @PrototypeChain as we'd love to understand if more info from when you ran into this issue is available. It'd help us ensure we don't replicate whatever was causing it as we work on the next version of these libraries.
Hi, Following up on this ticket. We have implemented the same caching strategy. When doing a hard refresh we get the fresh content while in normal cases we get the stale data. We have kept the TTL to 300 seconds. Below is the code for it
https://www.voot.com/service-worker.js
self.toolbox.router.get('/(.*)/getMegaMenus.json', self.toolbox.cacheFirst, { origin: /\.voot\.com/, "cache": { name: 'voot-assets-menu-js', maxEntries: 5, maxAgeSeconds: 300, }, });
Attached are the screenshots where in one of the screenshots you can see under Voot Originals -> Yo Ke Hua Bro which appears after the hard refresh
PS: Our website is restricted to India only as of now, incase you need to visit, you will need to use an Indian proxy.
I can't view https://www.voot.com/service-worker.js due to the georestrictions.
First, what version of sw-toolbox
are you using? There's code that checks whether a cached response is "fresh" before using it, but that was added in release 3.5.0
.
Assuming you're using 3.5.0
or later, can you confirm that your cached responses have proper Date:
headers set on them? The code to check whether a cached response is "fresh" relies on the Date:
header being available.
Thank you @jeffposnick to point this out. Will take it up and keep you apprised about the development.
In reference to Stack Overflow, All resources are getting cached as expected but they are not expiring on putting maxAgeSeconds. I have used
CacheFirst
Strategy, and verified that resources are kicking in through service worker cache. Also, I can see number of other cache storage (explicitly deleted caches usingcaches["delete"](e)
) in Application Tab->IndexDB which is not getting return by this statementcaches.keys().then(function(e) { console.log(e); })