title: PWA not working correctly offline. Uncaught (in promise) TypeError: Failed to fetch
body: <p>I am trying to convert a simple webpage I have into a PWA in case the site it uses goes down.</p>
  <p>I think I have done the majority of the work. The page is installable on my phone and passes all the Chrome lighthouse tests. But I get the following warning,</p>
  <pre><code>
  Web app manifest meets the installability requirements
  Warnings: Page does not work offline. The page will not be regarded as installable after Chrome 93, stable release August 2021.
  </code></pre>
  <p>I also get the following warning and error in console,</p>
  <pre><code>The FetchEvent for &quot;https://dannyj1984.github.io/index.html&quot; resulted in a network error response: the promise was rejected.
  Promise.then (async)
  (anonymous) @ serviceWorker.js:30
  serviceWorker.js:1 Uncaught (in promise) TypeError: Failed to fetch
  </code></pre>
  <p>There is then a warning saying the site cannot be installed as does not work offline. I have read the chrome dev article which says from the chrome release in Aug21 apps that dont work offline wont be installable. But I am stuck on which part of my fetch is causing an issue. The code in my service worker is,</p>
  <pre><code>const TGAbxApp = &quot;TG-ABX-App-v1&quot;
  const assets = [
    //paths to files to add
  
  ]
  
  self.addEventListener(&quot;install&quot;, installEvent =&gt; {
    installEvent.waitUntil(
      caches.open(TGAbxApp).then(cache =&gt; {
        cache.addAll(assets)
      })
    )
  })
  
  self.addEventListener('fetch', function(event) {
    event.respondWith(
      caches.match(event.request)
        .then(function(response) {
          // Cache hit - return response
          if (response) {
            return response;
          }
          return fetch(event.request);
        }
      )
    );
  });
  </code></pre>
  <p>The above code for the fetch part of the service worker I took from Google and as I understand it, it first checks if there is data in the cache stored on install, if not it will request it from the network.</p>