-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.js
45 lines (37 loc) · 1.13 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
// // set names for both precache & runtime cache
// workbox.core.setCacheNameDetails({
// prefix: 'day-of-code-guides',
// suffix: 'v1',
// precache: 'precache',
// runtime: 'runtime-cache'
// });
// // let Service Worker take control of pages ASAP
// workbox.skipWaiting();
// workbox.clientsClaim();
// // let Workbox handle our precache list
// workbox.precaching.precacheAndRoute(self.__precacheManifest);
// // use `networkFirst` strategy for `*.html`, like all my posts
// workbox.routing.registerRoute(
// /\.html$/,
// workbox.strategies.networkFirst()
// );
// // use `cacheFirst` strategy for images
// workbox.routing.registerRoute(
// /assets\/(img|icons)/,
// workbox.strategies.cacheFirst()
// );
// // use `networkFirst` strategy for `*.css`, like all my posts
// workbox.routing.registerRoute(
// /\.css$/,
// workbox.strategies.networkFirst()
// );
// // third party files
// workbox.routing.registerRoute(
// /^https?:\/\/cdn.staticfile.org/,
// workbox.strategies.staleWhileRevalidate()
// );
caches.keys().then(cacheNames => {
cacheNames.forEach(cacheName => {
caches.delete(cacheName);
});
});