Browse Source

Optimise truthy checks

pm2
Luke Childs 8 years ago
parent
commit
837f2a002c
  1. 10
      public/sw.js

10
public/sw.js

@ -34,12 +34,9 @@ self.addEventListener('fetch', function(event) {
event.respondWith( event.respondWith(
caches.match(event.request) caches.match(event.request)
.then(function(response) { .then(function(response) {
if (response) {
return response;
}
// If we don't have it make the request // If we don't have it make the request
return fetch(event.request); return response || fetch(event.request);
} }
) )
); );
@ -77,12 +74,9 @@ self.addEventListener('fetch', function(event) {
// Try and return a previously cached version // Try and return a previously cached version
return caches.match(event.request) return caches.match(event.request)
.then(function(response) { .then(function(response) {
if (response) {
return response;
}
// If we don't have a cached version show pretty offline page // If we don't have a cached version show pretty offline page
return caches.match(offlineUrl); return response || caches.match(offlineUrl);
}); });
}) })
); );

Loading…
Cancel
Save