-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
27 lines (26 loc) · 772 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
self.addEventListener("install", function(e) {
e.waitUntil(
caches.open("halogen-web-audio-player-demo").then(function(cache) {
return cache.addAll([
"./index.html",
"./index.html?homescreen=1",
"./dist/app.js",
"./dist/app.css"
]);
})
);
});
self.addEventListener("fetch", function(event) {
console.log(event.request.url);
fetch(event.request).catch(function() {
return caches.match(event.request).then(function(response) {
if (response) {
return response;
} else {
console.error("File Missing and cannot fetch while offline");
console.error("Event information: ", event)
throw new Error("File Missing and cannot fetch while offline");
}
});
});
});