Skip to content

Instantly share code, notes, and snippets.

@arackaf
Last active December 2, 2017 17:10
Show Gist options
  • Select an option

  • Save arackaf/a99db3f8e352b02dcc4403f7dfeede90 to your computer and use it in GitHub Desktop.

Select an option

Save arackaf/a99db3f8e352b02dcc4403f7dfeede90 to your computer and use it in GitHub Desktop.
async function preCacheBookImage(book) {
let smallImage = book.smallImage;
if (!smallImage) return;
let cachedImage = await caches.match(smallImage);
if (cachedImage) return;
if (/https:\/\/s3.amazonaws.com\/my-library-cover-uploads/.test(smallImage)) {
let cache = await caches.open("local-images1");
let img = await fetch(smallImage, { mode: "no-cors" });
await cache.put(smallImage, img);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment