FIX: Only show offline page when user is offline.

https://meta.discourse.org/t/cannot-load-app-in-firefox-sometimes-refresh-fixes-it/85258
This commit is contained in:
Guo Xiang Tan 2018-04-23 10:21:51 +08:00
parent 9eabf7c02c
commit d2d3c7d24e

View File

@ -80,7 +80,11 @@ self.addEventListener('fetch', function(event) {
// 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 (!navigator.onLine) {
return caches.match(OFFLINE_URL);
} else {
throw error;
}
})
);
}