I wrote and deployed a program to install ServiceWorker.
However, the overall performance of the service has fallen due to the ServiceWorker.
So, I decided to remove ServiceWorker from that service.
I have already deployed a service with ServiceWorker. Is this ServiceWorker not removed from the user's browser unless it is explicitly uninstalled on the program side?
Or will it automatically be removed over time from the browser of the user already running ServiceWorker?
Also, if I have to explicitly delete it, should I write the following code?
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
registration.unregister()
}
})
Browsers implement a call-home routine in which they automatically check for SW script updates when it's been 24 hours since the last time. In this check, the browser's HTTP cache is bypassed and the server will be consulted for a new version of the file. So in theory in a long enough time every client should automatically remove the SW.
However this auto-update was not in the initial SW implementations. If someone's using an old browser or some smaller browser without support for this then it might not be enough. For that reason, I would also use the unregister code you provided.
Use both.