How to update with Service Worker the Apps(PWA) Front Page

How do I update Progressive Web Apps landing page after the service worker install, without installing it again. The code works with other pages URLs, but does give one failed request if used for PWA front landing page. After the Chrome new SW update.

I get the page request from the cache and also update from the network like this, but PWAs front page gives failed fetch of the /. page. (You have to have the manifest file to get this error.)

		 if (event.request.mode === 'navigate') {
			 event.waitUntil((async () => {
				  try {
				 console.log(event.request.url);
				 	console.log(":update");
			 			 const cache = await caches.open(CACHE_NAME);
						  const cachedResponse = await cache.match(event.request);
				 if (cachedResponse) {
								 		 const networkResponse = await fetch(event.request);
		 if (networkResponse) {
			 				console.log(":updated");
			 cache.put(event.request, networkResponse.clone());	 
			 }
			 }
 } catch (error) {

	    }
			 })());
  }

Is there a way to update your(fetch from the network) PWAs front page without installing a new worker, after the Chrome update?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.