-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
38 lines (32 loc) · 779 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
32
33
34
35
36
37
38
importScripts(
"https://storage.googleapis.com/workbox-cdn/releases/3.1.0/workbox-sw.js"
);
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
} else {
console.log(`Boo! Workbox didn't load 😬`);
}
workbox.routing.registerRoute(
new RegExp(".*.js"),
workbox.strategies.networkFirst()
);
workbox.routing.registerRoute(
new RegExp(".*.html?.+"),
workbox.strategies.networkFirst()
);
workbox.routing.registerRoute(
/.*\.css/,
workbox.strategies.staleWhileRevalidate({
cacheName: "review-app-css-cache"
})
);
workbox.routing.registerRoute(
/.*\.jpg/,
workbox.strategies.staleWhileRevalidate({
cacheName: "review-app-image-cache"
})
);
workbox.precaching.precacheAndRoute([
{ url: "/index.html" },
{ url: "/restaurant.html" }
]);