Skip to content

Commit ee63351

Browse files
committed
test sw
1 parent cee8b3f commit ee63351

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎sw.js‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ self.addEventListener('fetch', function(event) {
3434
// Calling event.respondWith means we're in charge
3535
// of providing the response. We pass in a promise
3636
// that resolves with a response object
37-
event.respondWith(
38-
// First we look for something in the caches that
39-
// matches the request
40-
caches.match(event.request).then(function(response) {
41-
// If we get something, we return it, otherwise
42-
// it's null, and we'll pass the request to
43-
// fetch, which will use the network.
44-
return response || fetch(event.request);
45-
})
46-
);
37+
var requestURL = new URL(event.request.url);
38+
if (requestURL.origin == location.origin) {
39+
event.respondWith(
40+
// First we look for something in the caches that
41+
// matches the request
42+
caches.match(event.request).then(function(response) {
43+
// If we get something, we return it, otherwise
44+
// it's null, and we'll pass the request to
45+
// fetch, which will use the network.
46+
return response || fetch(event.request);
47+
})
48+
);
49+
}
4750
});

0 commit comments

Comments
 (0)