-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
41 lines (36 loc) · 1010 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
41
let cache_name = 'unitext_v413'
let precache_urls = [
'',
'/',
'/index.html',
'/build/webgl_413.data.unityweb',
'/build/webgl_413.json',
'/build/webgl_413.wasm.code.unityweb',
'/build/webgl_413.wasm.framework.unityweb',
'/build/UnityLoader.js'
]
self.addEventListener('install', (e) => {
console.log("Service install");
event.waitUntil(
caches.open(cache_name).then(function(cache) {
return cache.addAll(precache_urls);
}).then(function() {
return self.skipWaiting();
})
);
});
self.addEventListener('activate', (e) => {
console.log("Service activate");
return self.clients.claim();
});
self.addEventListener('fetch', function(event) {
event.respondWith(
fetch(event.request).then(function(response) {
caches.open(cache_name).then(function(cache) {
cache.put(event.request, response.clone());});
return response;
}).catch(function() {
return caches.match(event.request);
})
);
});