Delayed worker update

I have a web application that works and relies on service workers to check all cached files and make sure that users are in the correct version of the application.

Our client currently wants the device to check for updates at certain points (when you re-open the application), etc., since currently it may take up to 5 minutes to open the application before the device implements it on an outdated version.

Is it possible to get the device to check the service worker for any new changes, and not wait while the application checks me?

Thank!

+1
source share
1

, SW.

1) navigator.serviceWorker.register

, SW navigator.serviceWorker.register().

register() . , . , , PWA, 2 , , register() .

, , , . sw.js. SW .

2)

activate , SW clients. , , , / . . MDN :

.. ​​ , . , , . , .

skipWaiting() Clients.claim()

, MDN. , :

self.addEventListener('install', function(event) {
  event.waitUntil(self.skipWaiting());
});
self.addEventListener('activate', function(event) {
  event.waitUntil(self.clients.claim());
});
+1

Source: https://habr.com/ru/post/1668046/


All Articles