Created
October 28, 2019 14:16
-
-
Save thepassle/51985ddfcc326b91a71bf4d140c8e302 to your computer and use it in GitHub Desktop.
strategies11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('fetch', function(event) { | |
event.respondWith( | |
caches.open('my-app').then(function(cache) { | |
return cache.match(event.request).then(function(response) { | |
const fetchPromise = fetch(event.request).then(function(networkResponse) { | |
cache.put(event.request, networkResponse.clone()); | |
return networkResponse; | |
}) | |
return response || fetchPromise; | |
}) | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment