PageSourceSearch

https://elearn.chipxpert.in/sw.js

js chipxpert.in collected 2026-10-08 13:46:45 UTC 1,474 bytes, 39 lines download raw bytes

1const CACHE = 'chipxpert-pwa-v1';
2const PRECACHE = ['/offline.html', '/pwa/icon-192.png', '/pwa/icon-512.png'];
3
4self.addEventListener('install', (e) => {
5  e.waitUntil(caches.open(CACHE).then((c) => c.addAll(PRECACHE)).then(() => self.skipWaiting()));
6});
7
8self.addEventListener('activate', (e) => {
9  e.waitUntil(
10    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
11      .then(() => self.clients.claim())
12  );
13});
14
15self.addEventListener('fetch', (e) => {
16  const req = e.request;
17  if (req.method !== 'GET') return;                       // never cache POST/auth actions
18  const url = new URL(req.url);
19  if (url.origin !== self.location.origin) return;        // only same-origin
20  // Don't cache dynamic/auth/admin/api endpoints
21  if (/\/(admin|api|login|eda_metrics|unsubscribe)\b/.test(url.pathname)) return;
22
23  // Navigations: network-first, fall back to offline page
24  if (req.mode === 'navigate') {
25    e.respondWith(fetch(req).catch(() => caches.match('/offline.html')));
26    return;
27  }
28  // Static assets: stale-while-revalidate
29  if (/\.(css|js|png|jpe?g|gif|svg|webp|woff2?|ttf|ico)$/.test(url.pathname)) {
30    e.respondWith(
31      caches.open(CACHE).then((cache) =>
32        cache.match(req).then((cached) => {
33          const net = fetch(req).then((res) => { if (res.ok) cache.put(req, res.clone()); return res; }).catch(() => cached);
34          return cached || net;
35        })
36      )
37    );
38  }
39});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.