-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathservice-worker.js
44 lines (37 loc) · 1009 Bytes
/
service-worker.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
36
37
38
39
40
41
42
43
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js');
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
} else {
console.log(`Boo! Workbox didn't load 😬`);
}
workbox.routing.registerRoute(
// Cache CSS files.
/index\.html$/,
new workbox.strategies.CacheFirst({
// Use a custom cache name.
cacheName: 'html-cache',
plugins: [
new workbox.expiration.Plugin({
// Cache for a maximum of a week.
maxAgeSeconds: 7 * 24 * 60 * 60,
})
],
})
);
/*
workbox.routing.registerRoute(
// Cache CSS files.
/\.css$/,
// Use cache but update in the background.
new workbox.strategies.StaleWhileRevalidate({
// Use a custom cache name.
cacheName: 'css-cache',
})
);
*/
workbox.routing.registerRoute(
/\.php$/,
new workbox.strategies.NetworkFirst()
);
// cli will replace this
workbox.precaching.precacheAndRoute([]);