-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice-worker.js
45 lines (41 loc) · 962 Bytes
/
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
importScripts(
"https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"
);
const routing = workbox.routing;
const strategies = workbox.strategies;
workbox.routing.registerRoute(
/.(?:css|js|jsx|json)(?|$)/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: "assets",
plugins: [
new workbox.expiration.Plugin({
maxEntries: 1000,
maxAgeSeconds: 31536000,
}),
],
})
);
workbox.routing.registerRoute(
/.(?:png|jpg|jpeg|gif|woff2)$/,
new workbox.strategies.CacheFirst({
cacheName: "images",
plugins: [
new workbox.expiration.Plugin({
maxEntries: 1000,
maxAgeSeconds: 31536000,
}),
],
})
);
workbox.routing.registerRoute(
/(\/)$/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: "startPage",
plugins: [
new workbox.expiration.Plugin({
maxEntries: 1000,
maxAgeSeconds: 31536000,
}),
],
})
);