-
Notifications
You must be signed in to change notification settings - Fork 25
/
sw-precache-config.js
34 lines (34 loc) · 972 Bytes
/
sw-precache-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
// we overwrite the default service worker config to enable runtimeCaching
module.exports = {
stripPrefix: 'build/',
staticFileGlobs: [
'build/**/*.html',
'build/**/*.svg', // all svgs
'build/images/*.+(jpg|png|gif)',
'build/images/uploads/**/*10.+(jpg|png|gif)', // 10px resized images
'build/**/*.ico',
'build/**/*.json',
'build/static/**/!(*map*)',
'build/manifest.json'
],
dontCacheBustUrlsMatching: /\.\w{8}\./,
swFilePath: 'build/service-worker.js',
// any external urls you wish to cache (e.g. CDN)
runtimeCaching: [
{
// cache content from external url as they are loaded by browser
urlPattern: /^https?:\/\/.*example-cdn.com/,
handler: 'cacheFirst'
},
{
// cache files in the images directory as they are loaded by browser
urlPattern: '/images/(.*)',
handler: 'cacheFirst',
options: {
cache: {
name: 'images-cache'
}
}
}
]
}