From 92f6d8372c4e0747179b7ed3c8cda88b47fb9f6c Mon Sep 17 00:00:00 2001 From: kontrollanten Date: Wed, 21 Mar 2018 12:35:41 +0100 Subject: [PATCH] docs(example): add description of fallback handling --- docs/src/sw.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/sw.js b/docs/src/sw.js index 4db6962..c3f4d2f 100644 --- a/docs/src/sw.js +++ b/docs/src/sw.js @@ -145,9 +145,13 @@ self.addEventListener('fetch', event => { return responseNetwork }) .catch(() => { - // User is landing on our page. if (event.request.mode === 'navigate') { - return global.caches.match('./') + // If user navigation failed, let's provide an offline fallback + // to inform them properly. + // + // offline-fallback.html should be defined in servierWorkerOption.assets + // to ensure it's always cached. + return global.caches.match('./offline-fallback.html') } return null