Skip to content

Instantly share code, notes, and snippets.

@alexpermiakov
Last active December 23, 2019 12:52
Show Gist options
  • Save alexpermiakov/bc80630b5d5d69841a0e51f117d45395 to your computer and use it in GitHub Desktop.
Save alexpermiakov/bc80630b5d5d69841a0e51f117d45395 to your computer and use it in GitHub Desktop.
const CACHE_NAME = 'cache-v1';
const urlsToCache = ['/', '/css/main.css', '/js/main.js'];
self.addEventListener("install", async e => {
e.waitUntil(cacheResources());
});
const cacheResources = async () => {
const cache = await caches.open(CACHE_NAME);
return cache.addAll(urlsToCache);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment