serviceworker-webpack-plugin
serviceworker-webpack-plugin copied to clipboard
Example: Fallback to './' upon navigate mode?
Thank's for a great example to getting started using service workers. I just got a question regarding the following part:
.catch(() => {
// User is landing on our page.
if (event.request.mode === 'navigate') {
return global.caches.match('./')
}
return null
})
Why do we fall back to global.caches.match('/')
upon navigate? What is the "expected" scenario that this will happen? If we have /
cached, it will be returned immediately, or am I missing something?
We'll look into updating the example with perhaps some better defaults.
What I tend to do fall back on some fallback page, for example "/offline.html" and ensure that to be in the cache.
Ah, I see. I was too much into SPA thinking. Then it makes sense. Thanks for your answer!