-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
77 lines (70 loc) · 1.8 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
importScripts('/static/js/workbox-sw.prod.v2.1.3.js');/**
* @file service-worker.js with workbox api
* @desc [example](https://workbox-samples.glitch.me/examples/workbox-sw/)
* @author YanDong([email protected])
*/
/* globals WorkboxSW */
const workboxSW = new WorkboxSW({
cacheId: 'lavas-cache',
ignoreUrlParametersMatching: [/^utm_/],
skipWaiting: true,
clientsClaim: true
});
// Define precache injection point.
workboxSW.precache([
{
"url": "/index.html",
"revision": "f7d40177536a0e3fde0d48688daa0e7e"
},
{
"url": "/static/css/index.66ee3073.css"
},
{
"url": "/static/fonts/MaterialIcons-Regular.012cf6a1.woff"
},
{
"url": "/static/fonts/MaterialIcons-Regular.a37b0c01.ttf"
},
{
"url": "/static/img/music-icon.8a348576.svg"
},
{
"url": "/static/js/index.1ddf179b.js"
},
{
"url": "/static/js/manifest.7253881e.js"
},
{
"url": "/static/js/vendor.bf4c5fd6.js"
},
{
"url": "/static/js/vue.cf6433b2.js"
},
{
"url": "/static/js/workbox-sw.prod.v2.1.3.js",
"revision": "a9890beda9e5f17e4c68f42324217941"
}
]);
workboxSW.router.registerNavigationRoute('/index.html');
/**
* example runningCache with api
*/
// workboxSW.router.registerRoute(/^https:\/\/lavas\.baidu\.com\/some\/api/,
// workboxSW.strategies.networkFirst());
/**
* example runningCache with resources from CDN
* including maxAge, maxEntries
* cacheableResponse is important for CDN
*/
// workboxSW.router.registerRoute(/^https:\/\/cdn\.baidu\.com/i,
// workboxSW.strategies.cacheFirst({
// cacheName: 'lavas-cache-images',
// cacheExpiration: {
// maxEntries: 100,
// maxAgeSeconds: 7 * 24 * 60 * 60
// },
// cacheableResponse: {
// statuses: [0, 200]
// }
// })
// );