Worker doesn't seem to be caching
I just want to get a bit of advice on caching, and what I'm experiencing. I'm using this code https://pastebin.com/0kDUVewt to cache my website, and adding a query parameter to differentiate between mobile and desktop. It seems to be working, but there seems to be some cache fragmentation or something.
Basically, when I visit my site, it shows a hit, but the 'age' seems to be a very low number. I.e, if I visit, and then revisit in about 5 minutes, the 'age' is back at 0, which I believe is telling me that the cached version I'm seeing is new, and not the same version from the cache that I was seeing 5 minutes ago. Does anyone have any ideas, or tips on how to solve this? Sometimes if I refresh, I'm seeing the age of the cache'd version back at 0?
Pastebin
addEventListener('fetch', event => { event.respondWith(handleReq...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
2 Replies
Cache is just a cache it’s not guaranteed to live the full length you set. If you don’t have consistent requests it will be evicted from the cache to allow room for assets that are requested frequently
Understood; but it seems a bit odd that it’s being evicted after every refresh?