forked from devadvance/terminalcheatsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
31 lines (25 loc) · 748 Bytes
/
sw.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
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
if (workbox) {
console.log(`Workbox loaded`);
workbox.routing.registerRoute(
new RegExp('/(.*)'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'tcs',
})
);
workbox.routing.registerRoute(
/.*(?:ampproject)\.org.*\.(?:js)$/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'amp-project',
})
);
workbox.routing.registerRoute(
/^https:\/\/fonts\.googleapis\.com/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'google-fonts',
})
);
workbox.precaching.cleanupOutdatedCaches();
} else {
console.log(`Workbox didn't load`);
}