I run a standard Nginx reverse proxy with instructions from one of the official tutorials with DigitalOcean.
In the past few weeks, I started to notice (and others, too) random “Cannot Load App” messages when visiting the forum. Just randomly and semi-rarely. Refreshing with F5 instantly shows the site again.
I have the same issue, that always happens when I closed the browser with tabs saved and re open it. Than I get that messege and I need to refresh the page.
I think the message that we send when fetch throws an error is confusing.
fetch(event.request).catch(function(error) {
// The catch is only triggered if fetch() throws an exception, which will most likely
// happen due to the server being unreachable.
// If fetch() returns a valid HTTP response with an response code in the 4xx or 5xx
// range, the catch() will NOT be called. If you need custom handling for 4xx or 5xx
// errors, see https://github.com/GoogleChrome/samples/tree/gh-pages/service-worker/fallback-response
return caches.match(OFFLINE_URL);
If the server is unreachable, it doesn’t mean that the client is offline and I think this is why a lot of people are getting confused.
I wonder if the support load the offline service worker generates justifies the benefit it provides on desktop, on Android it is fine, but gain on desktop is sketchy
I had this great idea that we should only display the offline page by figuring out what type of error we’re getting. However…
A fetch() promise will reject with a TypeError when a network error is encountered or CORS is misconfigured on the server side, although this usually means permission issues or similar
So I experimented locally and get the same error, TypeError: Failed to fetch, whether I am offline or whether the server is down. No way of telling why the fetch request fails. The console does log net::ERR_CONNECTION_REFUSED but that is not available to us…
Even a Google Engineer wrote this in his blog post…
This is hands down, one of the worst error messages I’ve ever seen.
Nice I didn’t know about navigator.onLine. Since it is widely supported, the service worker will now display the cached offline page only when the user is offline.