main.js // Make Sure service work is supported if ( ' serviceWorker ' in navigator ){ console . log ( ' Service work is supported ' ); window . addEventListener ( ' load ' , () => { navigator . serviceWorker . register ( ' ./sw_cached_pages_V2.js ' ) . then ( reg => console . log ( " Service Worker: Registered " )) . catch ( err => console . log ( ` Service Worker: Error : ${ err } ` )) }) } sw_cached_pages_V2.js // Service Worker Fetch all data from sites const cacheName = " v2 " ; // call install Events self . addEventListener ( ' install ' , function ( event ) { }); // call Activate Events self . addEventListener ( ' activate ' , e => { console . log ( " ServiceWorker: Activated " ); e . waitUntil ( caches . keys (). then ( cacheNames => { return Promise . all ( ...
Comments
Post a Comment