Skip to content

Instantly share code, notes, and snippets.

@steph-crown
Last active January 28, 2022 13:24
Show Gist options
  • Save steph-crown/04c157fb20392589dfbc0c145763afcb to your computer and use it in GitHub Desktop.
Save steph-crown/04c157fb20392589dfbc0c145763afcb to your computer and use it in GitHub Desktop.
A service worker file
// Listens to an install event
self.addEventListener("install", (event) => {
event.waitUntil(
// We try to open a cache named "assets".
// If it does not exist, a new one will be created and named "assets"
caches.open("assets").then((cache) => {
// Add an array of path to files you want to add to cache
return cache.addAll([
"./",
"./css/index.css",
"./assets/logo192.png",
"./assets/logo512.png",
]);
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment