-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathworker.js
More file actions
35 lines (32 loc) · 683 Bytes
/
worker.js
File metadata and controls
35 lines (32 loc) · 683 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
const filesToCache = [
"AngryBirds.htm",
"AngryBirds.json",
"AngryBirds.png",
"AngryBirdsFavIcon_16x16.png",
"AngryBirdsFavIcon_192x192.png",
"AngryBirdsFavIcon_512x512.png",
"AngryBirdsGame.htm",
"AngryBirdsGame.js",
"AngryBirdsShare.png"
];
const staticCacheName = "angrybirds-v1";
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 => {
})
);
});