-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
25 lines (25 loc) · 847 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
const cacheName = "DigitalerSchulhof";
// self.addEventListener("install", () => {});
self.addEventListener("activate", () => {
// caches.delete(cacheName);
});
self.addEventListener("fetch", function (event) {
if (event.request.method === "GET" && event.request.url.indexOf("http") === 0) {
event.respondWith(
caches.open(cacheName).then(async function (cache) {
const response = await cache.match(event.request);
if (response) {
fetch(event.request).then(function (response_1) {
cache.put(event.request, response_1.clone());
return response_1;
});
return response;
}
return fetch(event.request).then(function (response_2) {
cache.put(event.request, response_2.clone());
return response_2;
});
})
);
}
});