Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

maxAgeSeconds in sw-toolbox #207

Open
numberknot opened this issue Nov 23, 2016 · 5 comments
Open

maxAgeSeconds in sw-toolbox #207

numberknot opened this issue Nov 23, 2016 · 5 comments

Comments

@numberknot
Copy link

numberknot commented Nov 23, 2016

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 using caches["delete"](e) ) in Application Tab->IndexDB which is not getting return by this statement caches.keys().then(function(e) { console.log(e); })

@jeffposnick
Copy link
Contributor

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.

@addyosmani
Copy link
Contributor

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.

@sohin-keshwani
Copy link

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

uncached-data-from-sw
cached-data-from-sw

PS: Our website is restricted to India only as of now, incase you need to visit, you will need to use an Indian proxy.

@jeffposnick
Copy link
Contributor

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.

@sohin-keshwani
Copy link

Thank you @jeffposnick to point this out. Will take it up and keep you apprised about the development.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants