I am following a simple PWA tutorial, but when I complete it I get the following console error,
Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed
Here is my serviceworker file
const staticDevCoffee = "dev-coffee-site-v1"
const assets = [
"/",
"/test.html",
"/csstest/style.css",
"/jstest/app.js",
"/coffee.png",
]
self.addEventListener("install", installEvent => {
installEvent.waitUntil(
caches.open(staticDevCoffee).then(cache => {
cache.addAll(assets)
})
)
})
When I run lighthouse tests, I get this,
start_url does not respond with a 200 when offlineThe start_url did respond, but not via a service worker.
This is my first look at PWAs so I am a little stuck. I have tried several solutions I have found on SO, but none work.
For the first exception:-
Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed
You get this exception when any files which you have mentioned in your cache list return a 404 response. So make sure the all the resources are giving 200.
For the 2nd error:-
start_url does not respond with a 200 when offlineThe start_url did respond.
In your case as files are not getting cached(due to first exception) you are getting this error and also make sure to cache root index file in your cache list.