Skip to content

Instantly share code, notes, and snippets.

@Steph-crown
Last active Jan 28, 2022
Embed
What would you like to do?
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