-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
41 lines (39 loc) · 1.18 KB
/
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
39
40
41
importScripts('./cache-polyfill.js');
self.addEventListener('install', function (e) {
e.waitUntil(
caches.open('maxClick-sw1').then(function (cache) {
return cache.addAll([
'./',
'./index.html',
'./src/css/style.css',
'./dist/bundle.js',
'./src/sound/blaster2.mp3',
'./src/images/level-0.jpg',
'./src/images/level-1.jpg',
'./src/images/level-2.jpg',
'./src/images/level-3.jpg',
'./src/images/level-4.jpg',
'./src/images/level-5.jpg',
'./src/images/level-6.jpg',
'./src/images/level-7.jpg',
'./src/images/level-8.jpg',
'./src/images/level-9.jpg',
'./src/images/level-10.jpg',
'./src/images/level-11.jpg',
'./src/images/level-12.jpg'
]);
})
);
});
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.open('maxClick-sw1').then(function (cache) {
return cache.match(event.request).then(function (response) {
return response || fetch(event.request).then(function (response) {
cache.put(event.request, response.clone());
return response;
});
});
})
);
});