However, I removed gatsby-plugin-offline (and all references to it) from my site months ago (and many deploys ago).
My 2 questions are:
Why is my browser still creating caches for gatsby-plugin-offline? (currently Chrome but this happens in a variety of browsers and platforms).
Is there a way to prevent this from happening in the future without manually deleting the cache storage?
I found references to a similar problem in this post and this post that mention unregistering service workers and am wondering if that’s related.
Thanks for any help you can offer!
To answer your questions:
- You removed the plugin from Gatsby. You didn’t tell browsers to unregister your service worker. This won’t automatically happen. To programatically unregister it, follow this:
- Yes, you need to set and control your caching strategies effectively. You should configure a way for yourself to be able to take over the control of a page when you need to. I personally do this by versioning the service worker. I check for the latest version on the server and invalidate the local cache + unregister the older worker and accept the new one.
Thanks! Also realized that the docs recommend replacing
I’m no longer seeing service workers so thanks for your help and explanations!