const CACHE_NAME = "my-kacil-v1";
const urlsToCache = [
  "/",
  "/assets/css/argon-dashboard.css?v=2.0.4",
  "/script.js",
  "/assets/img/logo.png",
  "/assets/img/logo.png",
];

self.addEventListener("install", (event) => {
  event.waitUntil(
    caches.open(CACHE_NAME).then((cache) => {
      console.log("Opened cache");
      return cache.addAll(urlsToCache);
    })
  );
});

self.addEventListener("fetch", (event) => {
  event.respondWith(
    caches.match(event.request).then((response) => {
      if (response) {
        return response;
      }
      return fetch(event.request);
    })
  );
});
