-
Notifications
You must be signed in to change notification settings - Fork 1
/
sw.js
40 lines (35 loc) · 898 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
39
40
const CACHE_NAME = 'tower-of-hanoi-v1';
const URLS_TO_CACHE = [
'index.html',
'style.css',
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js',
'script.js',
'manifest.json',
'assets/me.jpg',
'assets/icon/48x48.png',
'assets/icon/72x72.png',
'assets/icon/96x96.png',
'assets/icon/120x120.png',
'assets/icon/144x144.png',
'assets/icon/168x168.png',
'assets/icon/192x192.png'
];
self.addEventListener('install', function(installation) {
installation.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache){
return cache.addAll(URLS_TO_CACHE);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
if(response) {
return response;
}
return fetch(event.request);
})
);
});