[w3c/ServiceWorker] Immediate Service Worker (#1389)

If _offline-first_ app is deployed, then visited by users and later updated, these users do not see changes immediately on next visit. During the next visit SW is just updated. These changes are reflected after closing the tab, so effectively visible on future (if ever) visit. 

In scenarios your new version is publicly announced and users are encouraged to visit the site again to enjoy new features, this offline-first approach (in the current form) is almost useless.

Such announcement should be complemented by very complicated instructions 'after visiting the page wait few seconds (to update cache), then close all tabs with the app (or the entire browser) and finally open the app again'. 

Besides offline-first, aka 'Cache falling back to the network', there are other strategies:
https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker
https://redfin.engineering/how-to-fix-the-refresh-button-when-using-service-workers-a8e27af6df68

All seems to be overcomplicated for the above scenario. So I am suggesting another approach:

My proposal:

1. Incorporating a new SW type, distinguished by a dedicated property `immediate`, which could be set to `true` (by default false).
2. If page is to be served via SW and new SW version is detected and its immediate property is set to true, the current SW is ignored in this tab and new _immediate_ SW is installed (+ cached) virtually.
3. This SW is activated immediately, but not firing `activate` event. It is serving requests only for the given tab.
4. If older SW becomes obsolete (after the tab with older version is closed) while new tab is still open, new immediate SW will become proper SW and `activate` event is fired.
5. If tab with the virtual SW is closed before it was activated properly, all virtual stuff is removed.

This would be appreciated by both users and frontend developers. The complexity is moved into the browser code.

Thanks for considering.

-- 
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/1389

Received on Monday, 18 February 2019 20:20:08 UTC