Reputation: 1060
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?
Link: http://ashutoshysingh.com/sw.js
Update 1: I have readded the index.html file in cache.
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.'.
The FetchEvent for "https://www.ashutoshysingh.com/" resulted in a network error response: the promise was rejected.
Upvotes: 2
Views: 1896
Reputation: 2058
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',
...,
Upvotes: 0