const CACHE_NAME = "colorjet-v5-static-cache";
const ASSETS = [
  "/",
  "/index.html",
  "/assets/css/style.css",
  "/assets/js/main.js",
  "/assets/images/colorjet-logo.png",
  "/assets/images/favicon.png",
  "/products/index.html",
  "/blog/index.html",
  "/contact/index.html"
];

self.addEventListener("install", event => {
  event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS)).catch(() => null));
});

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