In my project I have used a Service worker just for updating the cached files after any new deployment takes place. And there are multiple sites with the same domain that have been used.
The issue I am facing is this: If I go through one site to another site then it is moving back to 1st site showing the page not found. For example, I have opened the URL 'domain.com/site1/profile/1' in one tab, and in another tab, I am opening 'domain.com/site2/profile/2' then It is redirecting to 'domain.com/site1/profile/2' and shows page-not-found. --- I analyzed the problem and got to know there are two service workers are active for the site1 as well as the site2.
Is there any way I can unregister the previous service worker i.e. of site1 if the new service worker of site2 been found and vice versa?
I also have tried the solution provided by @tony, but didnt get any luck. Please refer attached image after applying the solution. enter image description here