PageSourceSearch

https://www.wisenri.ai/sw.js

js wisenri.ai collected 2026-10-05 15:18:22 UTC 1,934 bytes, 76 lines download raw bytes

1const CACHE = "wisenri-v1";
2
3// Static shell to pre-cache so the app loads even offline
4const PRECACHE = [
5  "/",
6  "/manifest.json",
7  "/logo.png",
8  "/icons/icon-192x192.png",
9  "/icons/icon-512x512.png",
10];
11
12self.addEventListener("install", (event) => {
13  event.waitUntil(
14    caches.open(CACHE).then((cache) => cache.addAll(PRECACHE))
15  );
16  self.skipWaiting();
17});
18
19self.addEventListener("activate", (event) => {
20  event.waitUntil(
21    caches.keys().then((keys) =>
22      Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
23    )
24  );
25  self.clients.claim();
26});
27
28self.addEventListener("fetch", (event) => {
29  const { request } = event;
30  const url = new URL(request.url);
31
32  // Only handle same-origin GET requests
33  if (request.method !== "GET" || url.origin !== self.location.origin) return;
34
35  // Skip Next.js internals and API routes — always network
36  if (
37    url.pathname.startsWith("/_next/") ||
38    url.pathname.startsWith("/api/") ||
39    url.pathname.startsWith("/__nextjs")
40  ) {
41    return;
42  }
43
44  // Static assets: cache-first
45  if (
46    url.pathname.startsWith("/icons/") ||
47    url.pathname.startsWith("/partners/") ||
48    url.pathname === "/logo.png" ||
49    url.pathname === "/favicon.png" ||
50    url.pathname === "/manifest.json"
51  ) {
52    event.respondWith(
53      caches.match(request).then((cached) =>
54        cached ?? fetch(request).then((res) => {
55          const clone = res.clone();
56          caches.open(CACHE).then((c) => c.put(request, clone));
57          return res;
58        })
59      )
60    );
61    return;
62  }
63
64  // Pages: network-first, fall back to cache, then offline shell
65  event.respondWith(
66    fetch(request)
67      .then((res) => {
68        const clone = res.clone();
69        caches.open(CACHE).then((c) => c.put(request, clone));
70        return res;
71      })
72      .catch(() =>
73        caches.match(request).then((cached) => cached ?? caches.match("/"))
74      )
75  );
76});

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.