forked from Revolution641/Sonic-Mania-Web-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
32 lines (30 loc) · 950 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
var _cacheName = 'sonicmania-9282022';
var _cacheFiles = [
'RSDKv5.html',
'RSDKv5.js',
'RSDKv5.wasm',
'https://files.catbox.moe/xsfgty.rsdk'
];
self.addEventListener('install', (e) => {
console.log('[Service Worker] Install');
e.waitUntil(
caches.open(_cacheName).then((cache) => {
console.log('[Service Worker] Caching all: Game executable and web files');
return cache.addAll(_cacheFiles);
})
);
});
self.addEventListener('fetch', (e) => {
e.respondWith(
caches.match(e.request).then((r) => {
console.log('[Service Worker] Fetching resource: '+e.request.url);
return r || fetch(e.request).then((response) => {
return caches.open(_cacheName).then((cache) => {
console.log('[Service Worker] Caching new resource: '+e.request.url);
cache.put(e.request, response.clone());
return response;
});
});
})
);
});