Service workers can be used to cache resources and provide offline support for your web app.

I had one for my old portfolio site. It cached the site so even without internet the site would load. Even though I had a new homepage, the old one showed up. But removing it turned out to be a bit of a pain. And without removing it, I could not view my new site.

Removing the Service Worker

After a bit of research, I found this Github Repo, which gave me the solution to the problem.

Adding this script to where the service worker was previously installed, will unregister the service worker.

self.addEventListener('install', function(e) {
  self.skipWaiting();
});
 
self.addEventListener('activate', function(e) {
  self.registration.unregister()
    .then(function() {
      return self.clients.matchAll();
    })
    .then(function(clients) {
      clients.forEach(client => client.navigate(client.url))
    });
});

In my case i put that file under /sw.js on my web server because that is the location where my service worker was installed.