blob: d593be78326e8cb416129bc83db59a4f91c43598 (
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
|
var name = 'opaqueInterceptCache';
// Cross origin request to ensure that an opaque response is used
var prefix = 'http://example.com/tests/dom/workers/test/serviceworkers/'
self.addEventListener('install', function(event) {
var request = new Request(prefix + 'notify_loaded.js', { mode: 'no-cors' });
event.waitUntil(
Promise.all([caches.open(name), fetch(request)]).then(function(results) {
var cache = results[0];
var response = results[1];
return cache.put('./sw_clients/does_not_exist.js', response);
})
);
});
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.open(name).then(function(cache) {
return cache.match(event.request);
}).then(function(response) {
return response || fetch(event.request);
})
);
});
|