[Support Guide] Understanding & unregistering service workers

Last reviewed by Netlify Support - November 2024

A service worker is a script that your browser runs in the background to accomplish a variety of tasks. Browsers cache service workers for 24 hours by default, and don’t update them when you reload your page. Therefore, you may have a service worker on your site which could prevent you from seeing the latest and greatest changes that you’ve made.

If you suspect a service worker is causing this issue, I recommend disabling/removing the service worker from your site and unregistering it to see your latest change. You can unregister by going to your browser dev tools, under 'Application > Service Workers', there will be an option to unregister your current service worker.

Alternatively, you can use the following snippet in a javascript file or in the dev tools console:

navigator.serviceWorker.getRegistrations().then(function(registrations) {
  for(let registration of registrations) {
    registration.unregister()
    document.location.reload()
} })

If you have a different issue with a service worker, or need more information, comment below!

1 Like

Browsers cache service workers for 24 hours by default

read up a bit on this and found this progressive web apps - Service worker JavaScript update frequency (every 24 hours?) - Stack Overflow

" The one exception to standard HTTP caching rules, and this is where the 24 hours thing comes in, is that browsers will always go to the network if the age of the service-worker.js entry in the HTTP cache is greater than 24 hours. So, functionally, there’s no difference in using a max-age of 1 day or 1 week or 1 year—they’ll all be treated as if the max-age was 1 day."

1 Like

I played around with Vue pwa and service workers and kept finding that my site serves an old version.
After refreshing then only do I see the new changes.

I removed the pwa plugin and unregistered the service worker as per your instructions.

How can I be sure that my other viewers are not experiencing the same problem.

Site: https://span.com.na

Problems caused by service worker canot be fixed from Netlify’s end. I don’t see any issue at the moment as I never visited your website before and it doesn’t seem to have a service worker now. The only ones you can verify the problem are the ones who have visited your site before and got the service worker installed.