I wish to remove the service worker for my website. In addition to removing manifest.json, service-worker.js etc, I was planning on running the following code in perpetuity.
export default async () => {
const registrations = await navigator.serviceWorker.getRegistrations();
for (const registration of registrations) {
await registration.unregister();
}
}
My understanding is that the above code, when run in a browser, will remove any registered service workers at the current domain.
My question though - is this really the simplest way? Is it true that a hard refresh will not remove a service worker, even when beyond its default lifespan 24 hours? Is the only other way for my users to have the service work removed going into DevTools?