Skip to content
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.

Service worker cache serving old files and not updating. #71

Open
KevinGulj opened this issue May 10, 2018 · 2 comments
Open

Service worker cache serving old files and not updating. #71

KevinGulj opened this issue May 10, 2018 · 2 comments
Labels

Comments

@KevinGulj
Copy link

Hello
I could really use some advice about initializing the service worker cache logic.
Right now the service worker installs and activates nicely when I clean the cache manually in browser.
But after the first installation the service worker always loads the first installed files.
const { assets } = global.serviceWorkerOption; << Shows the most updated assets but it does not serve them.

And I deploy the SW in index.js :
if (process.env.NODE_ENV === "production" && 'serviceWorker' in navigator) { const runtime = require('serviceworker-webpack-plugin/lib/runtime'); const registration = runtime.register(); }

My sw.js is pretty much a copy-paste from the docs:
https://paste.ofcode.org/aTrM9Z98ruHCfRdFrn8866

Thanks in advance for any feedback

@devCrossNet
Copy link
Collaborator

Hey, I had some issues when I started to use service workers, too. Have a look at this gist: https://gist.github.com/Rich-Harris/fd6c3c73e6e707e312d7c5d7d0f3b2f9, maybe you have one of these issues.

@KevinGulj
Copy link
Author

Hey, thanks. I got a lot of new information from there yes. And it seems to be working about fine, when closing the tab it mostly updates to new information(not always though).
But about deleting old caches, when new content is fetched.
The service worker logs that [SW] Deleting caches with cache name [ ${cacheName}]
But when I look in the application tab, what I would expect is only 1MB cached, as my bundle is about 1MB. But after I have deployed like 2-3 versions without cleaning cache, it shows 2-3MB.
Any ideas about where to start debugging this ?

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

No branches or pull requests

3 participants