-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.js
48 lines (43 loc) · 1.06 KB
/
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
46
47
48
importScripts(
"https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js"
);
workbox.routing.registerRoute(
/\.(?:png|gif|jpg|jpeg|webp|svg|ico)$/,
new workbox.strategies.CacheFirst({
cacheName: "images",
plugins: [
new workbox.expiration.ExpirationPlugin({
maxEntries: 60,
}),
],
})
);
workbox.routing.registerRoute(
/\.(?:mp3)$/,
new workbox.strategies.CacheFirst({
cacheName: "audios",
plugins: [
new workbox.expiration.ExpirationPlugin({
maxEntries: 60,
}),
],
})
);
workbox.routing.registerRoute(
/\.(?:html|css|js)$/,
new workbox.strategies.CacheFirst({
cacheName: "static-resources",
})
);
workbox.routing.registerRoute(
({ url }) => url.origin === "https://fonts.googleapis.com",
new workbox.strategies.CacheFirst({
cacheName: "google-fonts-stylesheets",
})
);
workbox.routing.registerRoute(
({ url }) => url.origin === "https://fonts.gstatic.com",
new workbox.strategies.CacheFirst({
cacheName: "google-fonts-webfonts",
})
);