-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathworkbox-config.js
More file actions
50 lines (50 loc) · 1.23 KB
/
workbox-config.js
File metadata and controls
50 lines (50 loc) · 1.23 KB
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
module.exports = {
globDirectory: 'build/',
globPatterns: [
'**/*.{js,css,html,png,jpg,jpeg,svg,ico,json,webp,woff,woff2,ttf,eot}'
],
swDest: 'build/service-worker.js',
runtimeCaching: [
{
// Cache images
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images',
expiration: {
maxEntries: 100,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
},
},
},
{
// Cache API requests
urlPattern: /^https:\/\/api\./,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'api-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 5 * 60, // 5 minutes
},
},
},
{
// Cache static assets
urlPattern: /\.(?:js|css|woff|woff2|ttf|eot)$/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'static-assets',
expiration: {
maxEntries: 100,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
},
},
},
],
skipWaiting: true,
clientsClaim: true,
sourcemap: false,
dontCacheBustURLsMatching: /\.\w{8}\./,
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, // 5MB
};