Skip to content

Commit

Permalink
Some Service Worker fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joelweinberger committed Aug 31, 2015
1 parent f98f83e commit e46adfc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions static/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var urlsToCache = [
'/index',
'/css/generic/basic-page.css',
'/css/generic/header.css',
'/css/generic/offline.css',
'/css/page/index.css',
'/img/greetings from newark.jpg',
'/img/joel-weinberger-headshot.jpg'
Expand All @@ -31,8 +30,7 @@ self.addEventListener('fetch', function(event) {
}

var fetchRequest = event.request.clone();

return fetch(fetchRequest).then(
var fetchResult = fetch(fetchRequest).then(
function(response) {
if (!response || response.status !== 200 || response.type !== 'basic') {
return response;
Expand All @@ -45,6 +43,14 @@ self.addEventListener('fetch', function(event) {
});
return response;
}
);
).catch(function() {
console.log("Failed to fetch " + fetchRequest.url);
});

if (response) {
return response;
}

return fetchResult;
}))
});

0 comments on commit e46adfc

Please sign in to comment.