-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathworker.js
More file actions
41 lines (38 loc) · 879 Bytes
/
worker.js
File metadata and controls
41 lines (38 loc) · 879 Bytes
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
const filesToCache = [
"/",
"Emulatrix.htm",
"Emulatrix.json",
"EmulatrixFavIcon_192x192.png",
"EmulatrixFavIcon_512x512.png",
"EmulatrixFavIcon.svg",
"EmulatrixShare.png",
"Emulatrix_DOS.js",
"Emulatrix_GameBoy.js",
"Emulatrix_GameBoyAdvance.js",
"Emulatrix_Genesis.js",
"Emulatrix_MAME.js",
"Emulatrix_Nintendo.js",
"Emulatrix_SuperNintendo.js",
"index.html",
]
const staticCacheName = "emulatrix-v2"
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(staticCacheName).then((cache) => {
return cache.addAll(filesToCache)
})
)
})
self.addEventListener("fetch", (event) => {
event.respondWith(
caches
.match(event.request)
.then((response) => {
if (response) {
return response
}
return fetch(event.request)
})
.catch((_error) => {})
)
})