-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathworkbox-config.js
59 lines (57 loc) · 1.38 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
module.exports = {
globDirectory: 'dist/',
globPatterns: [
'**/*.{png,ico,html,js,webmanifest,css}',
],
swDest: 'dist/sw.js',
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [
{
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images',
expiration: {
maxEntries: 60,
},
},
},
{
urlPattern: ({ url }) => (
['github.com', 'datascience.pe'].indexOf(url.hostname) >= 0
&& /\.png$/.test(url.pathname)
),
handler: 'CacheFirst',
options: {
cacheName: 'avatars',
cacheableResponse: {
statuses: [0, 200],
},
},
},
// Cache the Google Fonts stylesheets with a stale-while-revalidate strategy.
{
urlPattern: /^https:\/\/fonts\.googleapis\.com/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'google-fonts-stylesheets',
},
},
// Cache the underlying font files with a cache-first strategy for 1 year.
{
urlPattern: /^https:\/\/fonts\.gstatic\.com/,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-webfonts',
cacheableResponse: {
statuses: [0, 200],
},
expiration: {
maxEntries: 10,
maxAgeSeconds: 365 * 24 * 60 * 60, // 1 year
},
},
},
],
};