Open marcalj opened 7 years ago
Note that it should be registered with a scope: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
navigator.serviceWorker.register('/sw-test/sw.js', {scope: '/n-angular4/'})
NOTE: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
In Chrome Canary I'm getting this error:
Console: {"lineNumber":0,"message":"The FetchEvent for \"https://love.com/n-angular4/#!/auth/login\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":0,"message":"Uncaught (in promise) TypeError: Failed to fetch","message_level":3,"sourceIdentifier":1,"sourceURL":"https://love.com/n-angular4/worker-basic.min.js"}
I'm totally lost, I've been able to make it work in Chrome, but with a new version, when going offline it doesn't work now :/
In Firefox it seems that file ngsw-manifest.json
is not cached (is not declared in static.urls
and Firefox shows an corrupted error warning when offline because it cannot load it.
Firefox has some strange behaviour for respondWith()
method. Could you confirm the Failed to load .... A ServiceWorker passed a redirected Response to FetchEvent.respondWith() while RedirectMode is not ‘follow’.
error in DevTools?
This change should fix - it was only the beginning of the discussion. The actual fix is: https://github.com/GoogleChrome/sw-precache/pull/241Corrupted Content Error
in Firefox: https://github.com/GoogleChrome/sw-precache/pull/233/files
More context: https://github.com/GoogleChrome/sw-precache/issues/220 Technical background: https://bugs.chromium.org/p/chromium/issues/detail?id=669363&desc=2#c1
@alxhub, please have a look
In Chrome Canary I can inspect the first fetch:
I'm using
--base-href /n-angular4/
to build but it doesn't generate the correct paths in thengsw-manifest.json
file in dist folder.ngsw-manifest.json
After manually setting the new paths and clearing the Service Worker it's finally working.