Created
June 14, 2016 01:51
-
-
Save notionparallax/8a11ad093a89d097e30ec0b7b3039e3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function servePhoto(request) { | |
var storageUrl = request.url.replace(/-\d+px\.jpg$/, ''); | |
return caches.open(contentImgsCache).then(function(cache) { | |
return cache.match(storageUrl).then(function(response) { | |
if (response) return response; | |
return fetch(request).then(function(networkResponse) { | |
cache.put(storageUrl, networkResponse.clone()); | |
return networkResponse; | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment