[w3c/ServiceWorker] Very Strange Issue about refresh. (#1504)

This is the issue that I've been trying to handle and it's been some time since nobody really could answer. I hope my long explanation won't disturb you and you will do your best to explain this to me in the best way.

I appreciate it. I know this shouldn't be here and should be on stackoverflow, but there, it takes weeks to get answered. Let's begin.

Let's say I have a service worker registration directly in my `main.js` file.  (I don't register it in the `load` event). Now,  user opened our website for the first time.  So `install` and `activate`  event will happen. In `install`, we got putting things in temp cache and in `activate`, we remove the real cache and move temp cache into the real one. 

Scenario 1) I use skipwaiting in service worker's install event and we updated the app. 

User now refreshes the page, new service worker gets installed, and because of skipWaiting, it will also get activated. but, before finishing installing and activating, i am sure old service worker will be faster and old service worker would listen to fetch events of the page.  Which means that when we update some code and user refreshes the page, our old service worker still kicks off. So, with skipWaiting, user has to refresh 2 times to see my updated changes. **(Agree with what I said?)**

Scenario 2)  I use skipWaiting and clientsClaim and we updated the app.

I hate clientsClaim. even though when new service worker goes to activate event immediatelly because of skipWaiting and even though I have clientsClaim in activate event which should activate fetch listener immediatelly for new service worker, before all these happen, it's possible that old service worker still kicks off before installing/activating. and my changes still won't be seen if user doesn't refresh 2 times. (**Do you agree with me?** ) . So i don't think clientsClaim can help me with anything.

Scenario 3) I use Jake Archibald's solution where he refreshes programatically after user refreshes. So this case also refreshes 2 times, but user only refreshes once. 

The issue with this scenario is When user refreshes, I don't want her to see old site and after 500ms, he might see the new one. I know It is possible to just return header with 0, so that blank page will be shown, but still i don't like this idea.


**To sum up)**

1) when using SkipWaiting in install event,  I still need to refresh the page 2 times to see the changes.

2) when using SkipWaiting in install and clientsClaim in activate, i still need to refresh the page 2 times to see the changes.

3) Looks like the third scenario is the way to go?


What do you think of all these assumptions? Am I stuck? Any ideas? 

I'd really appreciate it .




-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1504

Received on Tuesday, 11 February 2020 09:08:53 UTC