-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathworkbox-config.js
61 lines (54 loc) · 1.24 KB
/
workbox-config.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
module.exports = {
// Specify files to precache
globDirectory: "dist/",
globPatterns: [
"**/*.{html,css,js,json,svg,ico}",
"json/*.json"
],
runtimeCaching: [
// Cache JSON files with a stale-while-revalidate strategy
{
urlPattern: /\.json$/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'json-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 // 24 hours
}
}
},
// Cache static assets
{
urlPattern: /\.(?:png|css|svg|ico)$/,
handler: 'CacheFirst',
options: {
cacheName: 'static-assets',
expiration: {
maxEntries: 20,
maxAgeSeconds: 60 * 60 * 24 * 7 // 7 days
}
}
},
// Cache HTML files
{
urlPattern: /\.html$/,
handler: 'NetworkFirst',
options: {
cacheName: 'html-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 // 24 hours
}
}
}
],
// Output path for service worker
swDest: "dist/sw.js",
// Don't generate sourcemaps
sourcemap: false,
// Skip waiting on install
skipWaiting: true,
// Claim clients immediately
clientsClaim: true
};