-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FYI: also available on Vite #10
Comments
First, regarding this ticket: this is good FYI. I assume specifically its this flag: https://vite-pwa-org.netlify.app/guide/unregister-service-worker.html#development. Second, some back story relevant to this ticket that might be helpful context if anyone lands here. I ran into a scenario where my domain was overtaken by Vite PWA. I'm new to service workers and for reasons I didn't figure out the website content would not refresh -- Vite PWA was not updating the content. I'm certain this was user error. My plan was to switch away from Vite PWA (and Vitesse entirely) to hugo. When I did this I found the old site was still loading (I expected this, because at this point I understood that the service worker registers and reads all the things from cache). So, I went down this muddy path of figuring out how to disable the service worker and/or its cache. Very important: I learned that the service worker js file that was registered (mine was at /sw.js) will automatically update (given certain assumptions). I found these resources helpful:
I resolved on a VERY similar solution to this project:
self.addEventListener('install', event => {
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
navigator.serviceWorker.getRegistrations().then(
function(registrations) {
for (let registration of registrations) {
registration.unregister();
}
}
);
}); I took inspiration from this StackOverflow answer: https://stackoverflow.com/a/33705250, though there are important differences. The problem was that it would throw an exception:
And, that's when I found this project! @NekR thank you, thank you, thank you. All that to say, if I had to do this all over again I might have tried the self-destruct on Vite, but that is not a permanent production solution. I truly need to figure out what I had done wrong in my configuration. Given how "sticky" service workers and Cache API are I suspect this project is very valuable. |
@josephdpurcell I'm including sw cache storage cleanup in |
vite-pwa/vite-plugin-pwa#323 (ready to review)
https://deploy-preview-323--vite-plugin-pwa.netlify.app/guide/unregister-service-worker.html
The text was updated successfully, but these errors were encountered: