Skip to content

Instantly share code, notes, and snippets.

@ukmadlz
Created May 10, 2017 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukmadlz/2c4f67d0d6499b9da265439e2665936c to your computer and use it in GitHub Desktop.
Save ukmadlz/2c4f67d0d6499b9da265439e2665936c to your computer and use it in GitHub Desktop.
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