Server IP : 162.240.98.243 / Your IP : 18.227.10.45 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/public_html/login.easenup.in/ |
Upload File : |
const cacheName = 'news-v1'; const staticAssets = [ './', './index.html', './styles.css', './index.js', './newsApi.js', './news-article.js' ]; self.addEventListener('install', async e => { const cache = await caches.open(cacheName); await cache.addAll(staticAssets); return self.skipWaiting(); }); self.addEventListener('activate', e => { self.clients.claim(); }); self.addEventListener('fetch', async e => { const req = e.request; const url = new URL(req.url); if (url.origin === location.origin) { e.respondWith(cacheFirst(req)); } else { e.respondWith(networkAndCache(req)); } }); async function cacheFirst(req) { const cache = await caches.open(cacheName); const cached = await cache.match(req); return cached || fetch(req); } async function networkAndCache(req) { const cache = await caches.open(cacheName); try { const fresh = await fetch(req); await cache.put(req, fresh.clone()); return fresh; } catch (e) { const cached = await cache.match(req); return cached; } }