blob: 9839fc5f071e0dc830151e815c33c8b2a502f178 (
plain)
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
|
var prefix = "/tests/dom/workers/test/serviceworkers/fetch/origin/https/";
function addOpaqueRedirect(cache, file) {
return fetch(new Request(prefix + file, { redirect: "manual" })).then(function(response) {
return cache.put(prefix + file, response);
});
}
self.addEventListener("install", function(event) {
event.waitUntil(
self.caches.open("origin-cache")
.then(c => {
return addOpaqueRedirect(c, 'index-https.sjs');
})
);
});
self.addEventListener("fetch", function(event) {
if (event.request.url.indexOf("index-cached-https.sjs") >= 0) {
event.respondWith(
self.caches.open("origin-cache")
.then(c => {
return c.match(prefix + 'index-https.sjs');
})
);
} else {
event.respondWith(fetch(event.request));
}
});
|