1

Service worker registration code :

(function () {
    'use strict';
    if ('serviceWorker' in navigator) {
        window.addEventListener('load', function () {
             navigator.serviceWorker.register('/sw.js').then(function (registration) {
            // Registration was successful
            console.log('ServiceWorker registration successful with scope: ', registration.scope);
           }).catch(function (err) {
            // registration failed :(
            console.log('ServiceWorker registration failed: ', err);
           });
        });
    }else{
        console.log('Browser does not support service workers');
    }
})();

Is it possible to check in the register block about the expiration time of service worker and update it programmatically?

Also any best practices while we are working on service-worker?

Samir
  • 691
  • 5
  • 22
  • Possible duplicate of [Service worker JavaScript update frequency (every 24 hours?)](http://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours) – Jeff Posnick Apr 25 '17 at 14:25

0 Answers0