Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cloudinary PWA React Blog
self.addEventListener("fetch", function (event) {
event.respondWith(
caches.open(cacheNameStatic).then(function(cache) {
return cache.match(event.request).then(function(response) {
var 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