-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsw.js
35 lines (32 loc) · 1.05 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.6.1/workbox-sw.js');
/*const navigationStrategy = workbox.strategies.networkFirst({
cacheName: 'nav-cache',
// Use the network unless things are VERY slow
// This gives the network time to get up.
networkTimeoutSeconds: 15,
plugins: [
new workbox.expiration.Plugin({
// Cache for a maximum of three days
maxAgeSeconds: 7 * 24 * 60 * 60,
})
],
});
const navigationRoute = new workbox.routing.NavigationRoute(navigationStrategy, {});
workbox.routing.registerRoute(navigationRoute);*/
workbox.routing.registerRoute(
// Cache files without a query string
/^[^?]+$/,
// Use the cache if it's available
workbox.strategies.networkFirst({
cacheName: 'everything-network-first',
// Use the network unless things are VERY slow
// This gives the network time to get up.
networkTimeoutSeconds: 15,
plugins: [
new workbox.expiration.Plugin({
// Cache for a maximum of three days
maxAgeSeconds: 7 * 24 * 60 * 60,
})
],
})
);