2

I created a pwa site which is working totally fine in android devices both online and offline. But it is throwing error FetchEvent.respondWith received an error: Returned response is null when tried to load on IOS device with safari 13.0 if the mobile device is offline.

Here is my code snippet from service_worker.js

// install event
self.addEventListener('install', evt => {
  evt.waitUntil(
    caches.open(staticCacheName).then((cache) => {
      return cache.addAll(assets);
    })
  );
});
// activate event
self.addEventListener('activate', (e) => {
  e.waitUntil(
    caches.keys().then((keyList) => {
          return Promise.all(keyList.map((key) => {
        if(key !== staticCacheName) {
          return caches.delete(key);
        }
      }));
    })
  );
});
//fetch event
 self.addEventListener('fetch', function(event) {
   event.respondWith(
     fetch(event.request).catch(function() {
       return caches.match(event.request,{ignoreSearch: true});
    })
    );
 });

Please, help me find the solution.

Sujay Prabhu
  • 151
  • 4
  • 14
  • have a look here https://stackoverflow.com/questions/33986976/how-can-i-remove-a-buggy-service-worker-or-implement-a-kill-switch – probhonjon Jun 22 '20 at 15:45

0 Answers0