PageSourceSearch

https://muhabbit.vercel.app/sw.js

js muhabbit.vercel.app collected 2026-10-03 07:21:08 UTC 2,086 bytes, 79 lines download raw bytes

1const CACHE_NAME = 'muhabbit-v1';
2const STATIC_ASSETS = [
3  '/',
4  '/news',
5  '/analytics',
6  '/turkiye',
7  '/favicon.svg',
8  '/og-image.png',
9];
10
11// Install - cache app shell
12self.addEventListener('install', (event) => {
13  event.waitUntil(
14    caches.open(CACHE_NAME).then((cache) => {
15      return cache.addAll(STATIC_ASSETS);
16    })
17  );
18  self.skipWaiting();
19});
20
21// Activate - clean old caches
22self.addEventListener('activate', (event) => {
23  event.waitUntil(
24    caches.keys().then((keys) => {
25      return Promise.all(
26        keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))
27      );
28    })
29  );
30  self.clients.claim();
31});
32
33// Fetch - network first for API, cache first for static
34self.addEventListener('fetch', (event) => {
35  const { request } = event;
36  const url = new URL(request.url);
37
38  // Skip non-GET requests
39  if (request.method !== 'GET') return;
40
41  // API calls: network first
42  if (url.hostname.includes('railway.app') || url.pathname.startsWith('/v1/')) {
43    event.respondWith(
44      fetch(request)
45        .then((response) => {
46          const clone = response.clone();
47          caches.open(CACHE_NAME).then((cache) => cache.put(request, clone));
48          return response;
49        })
50        .catch(() => caches.match(request))
51    );
52    return;
53  }
54
55  // Static assets: cache first
56  if (url.pathname.match(/\.(js|css|png|jpg|svg|ico|woff2?)$/)) {
57    event.respondWith(
58      caches.match(request).then((cached) => {
59        return cached || fetch(request).then((response) => {
60          const clone = response.clone();
61          caches.open(CACHE_NAME).then((cache) => cache.put(request, clone));
62          return response;
63        });
64      })
65    );
66    return;
67  }
68
69  // Pages: network first with cache fallback
70  event.respondWith(
71    fetch(request)
72      .then((response) => {
73        const clone = response.clone();
74        caches.open(CACHE_NAME).then((cache) => cache.put(request, clone));
75        return response;
76      })
77      .catch(() => caches.match(request).then((cached) => cached || caches.match('/')))
78  );
79});

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.