sw.js
const CACHE_NAME="site-cache-v1";
const urlsToCache=[
"/",
"/favicon.ico"
];
self.addEventListener("install",event=>{
event.waitUntil(
caches.open(CACHE_NAME).then(cache=>{
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener("fetch",event=>{
event.respondWith(
caches.match(event.request).then(response=>{
return response||fetch(event.request).then(fetchRes=>{
return caches.open(CACHE_NAME).then(cache=>{
cache.put(event.request,fetchRes.clone());
return fetchRes;
});
});
})
);
});

*Please Don't Spam Here. All the Comments are Reviewed by Admin.