-
Notifications
You must be signed in to change notification settings - Fork 1
/
sw.js
30 lines (27 loc) · 869 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
self.addEventListener('install', function(e){
e.waitUntil(
caches.open('restaurants').then(function(cache) {
return cache.addAll([
'/',
'/restaurant.html?id=1',
'/restaurant.html?id=2',
'/restaurant.html?id=3',
'/restaurant.html?id=4',
'/restaurant.html?id=5',
'/restaurant.html?id=6',
'/restaurant.html?id=7',
'/restaurant.html?id=8',
'/restaurant.html?id=9',
'/restaurant.html?id=10'
])
})
)
});
self.addEventListener('fetch', function(event) {
console.log(event.request.url);
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});