Skip to content

Instantly share code, notes, and snippets.

@thepassle
Created October 28, 2019 14:16
Show Gist options
  • Save thepassle/51985ddfcc326b91a71bf4d140c8e302 to your computer and use it in GitHub Desktop.
Save thepassle/51985ddfcc326b91a71bf4d140c8e302 to your computer and use it in GitHub Desktop.
strategies11
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