Added handling if the user is offline (#35)
This commit is contained in:
parent
2a7871cf96
commit
3211e1e8ea
6 changed files with 1167 additions and 127 deletions
|
|
@ -1,4 +1,21 @@
|
|||
/* eslint-disable no-console */
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
console.log('Hello from the service worker');
|
||||
// Cache assets
|
||||
workbox.routing.registerRoute(
|
||||
// This regexp matches all files in precache-manifest
|
||||
new RegExp('.+\\.(css|json|js|eot|svg|ttf|woff|woff2|png|html|txt)$'),
|
||||
new workbox.strategies.StaleWhileRevalidate()
|
||||
);
|
||||
|
||||
// Always send api reqeusts through the network
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp('(\\/)?api\\/v1\\/.*$'),
|
||||
new workbox.strategies.NetworkOnly()
|
||||
);
|
||||
|
||||
// Cache everything else
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp('.*'),
|
||||
new workbox.strategies.StaleWhileRevalidate()
|
||||
);
|
||||
|
|
|
|||
Reference in a new issue