blob: b74e8cd6a236bd7c4477910a064f366e3da8470b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
self.addEventListener('fetch', function(event) {
if (event.request.url.indexOf('sample.js') != -1) {
event.respondWith(new Promise(resolve => {
// Slightly delay the response so we ensure we get a non-zero
// duration.
setTimeout(_ => resolve(new Response('// Empty javascript')), 50);
}));
}
else if (event.request.url.indexOf('missing.jpg?SWRespondsWithFetch') != -1) {
event.respondWith(fetch('sample.txt?SWFetched'));
}
});
|