What is the proper way to delay a service worker update check?

Advertisements I’d like to only have the service worker update check occur eg 5 mins into the app being used. Problem is that because it’s wrapped in window.addEventListener(‘load’, async () => { navigator.serviceWorker.register("/serviceWorker.js"); const registration = await navigator.serviceWorker.getRegistration(); it starts its checks at load time. To get around it I put the service worker init… Read More What is the proper way to delay a service worker update check?

Can't pass data to serviceWorker once it's registered as it's null

Advertisements I’m new with serviceWorker and trying to pass data to it after it’s registered a way like navigator.serviceWorker.register(‘/serviceWorker.js’).then(function () { navigator.serviceWorker.controller.postMessage({‘hello’: ‘world’}); }); But I receive the error Cannot read properties of null (reading ‘postMessage’) >Solution : You can wait until service worker is ready and then post a message like this : if… Read More Can't pass data to serviceWorker once it's registered as it's null

Service worker fetch event passing in wrong type

Advertisements I add a fetch event listener like this self.addEventListener( ‘fetch’, fetch ) and here is my fetch function const fetch = e => { console.log({e}) if ( !e.request.url.startsWith( self.location.origin ) || e.request.method !== ‘GET’ ) return const save = async res => { const cache = await caches.open( dynamic ) cache.put( e.request, res )… Read More Service worker fetch event passing in wrong type