2
votes

I created a new website and added a service worker. It gets installed but refuses to work offline. I am loading all resources from cache explicitly by specifying all the URL's. Could someone explain why is the main request failing?

Requests snapshot

Link: http://ashutoshysingh.com/sw.js

Update 1: I have readded the index.html file in cache.

  1. Error shown in Firefox console:

Failed to load 'https://www.ashutoshysingh.com/'. A ServiceWorker passed a promise to FetchEvent.respondWith() that rejected with 'TypeError: NetworkError when attempting to fetch resource.'.

  1. Error in Chrome console:

The FetchEvent for "https://www.ashutoshysingh.com/" resulted in a network error response: the promise was rejected.

1

1 Answers

0
votes

You have to add your appshell (index.html or similar) to the cache as well:

caches.open(staticCacheName).then(function(cache) {
  return cache.addAll([
        '/', or 'index.html',
        'assets/css/styles.css',
        ...,