PageSourceSearch

https://bithouse.ai/sw.js

js bithouse.ai collected 2026-10-05 15:28:33 UTC 2,146 bytes, 75 lines download raw bytes

1const STATIC_CACHE = "bithouse-static-v14";
2
3/** Marketplace card heroes are version-bumped often; never serve a stale SW cache. */
4function isMarketplaceCardHero(pathname) {
5  return pathname.startsWith("/images/marketing/") && pathname.includes("-card-v");
6}
7
8/** Same-origin Next.js build assets only. */
9function isNextStaticAsset(pathname) {
10  return pathname.startsWith("/_next/static/");
11}
12
13/** Apple touch / home-screen icons must always use the network (avoid stale SW cache). */
14function isAppleTouchIcon(pathname) {
15  return (
16    pathname.includes("apple-touch-icon") ||
17    pathname === "/apple-icon.png"
18  );
19}
20
21/** Same-origin public shell assets shipped with the app (excluding Apple icons). */
22function isPublicStaticAsset(pathname) {
23  if (isAppleTouchIcon(pathname)) return false;
24  return pathname.startsWith("/images/") || pathname === "/icon.png";
25}
26
27self.addEventListener("install", () => {
28  self.skipWaiting();
29});
30
31self.addEventListener("activate", (event) => {
32  event.waitUntil(
33    caches
34      .keys()
35      .then((keys) =>
36        Promise.all(
37          keys
38            .filter((key) => key.startsWith("bithouse-static-") && key !== STATIC_CACHE)
39            .map((key) => caches.delete(key)),
40        ),
41      )
42      .then(() => self.clients.claim()),
43  );
44});
45
46self.addEventListener("fetch", (event) => {
47  if (event.request.method !== "GET") return;
48
49  const url = new URL(event.request.url);
50  if (url.origin !== self.location.origin) return;
51
52  if (url.pathname.startsWith("/api/")) return;
53  if (isAppleTouchIcon(url.pathname)) return;
54
55  if (isMarketplaceCardHero(url.pathname)) {
56    event.respondWith(fetch(event.request));
57    return;
58  }
59
60  const cacheable = isNextStaticAsset(url.pathname) || isPublicStaticAsset(url.pathname);
61  if (!cacheable) return;
62
63  event.respondWith(
64    caches.open(STATIC_CACHE).then(async (cache) => {
65      const cached = await cache.match(event.request);
66      if (cached) return cached;
67
68      const response = await fetch(event.request);
69      if (response.ok) {
70        await cache.put(event.request, response.clone());
71      }
72      return response;
73    }),
74  );
75});

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.