Browser: Firefox 58.0.2 (64-bit)
I am attempting to create a very basic service worker to store content for offline viewing, following the guidelines provided here and here.
After installing the service worker successfully upon loading the page for the first time, I noticed an error message when trying to refresh the page or navigate to another section of the site, whether online or offline:
The site at [my URL] has experienced a network protocol violation that cannot be repaired.
The page you are trying to view cannot be shown because an error in the data transmission was detected.
Please contact the website owners to inform them of this problem.
The console displayed the following error:
Failed to load ‘[my URL]’. A ServiceWorker passed a redirected Response to FetchEvent.respondWith() while RedirectMode is not ‘follow’.
In Chrome, a different error appeared:
Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': Cannot construct a Request with a Request whose mode is 'navigate' and a non-empty RequestInit.
Despite adding the { redirect: "follow" } parameter as suggested in this thread, the issue persisted even after manually uninstalling and reinstalling the Service Worker from the about:debugging page.
It seems like the problem lies within the response due to server redirects when serving the requested content. How can I handle these redirects while still caching the data appropriately?