PageSourceSearch

https://nehaberajansi.com/sw.js

js nehaberajansi.com collected 2026-10-06 01:01:58 UTC 1,726 bytes, 59 lines download raw bytes

1const CACHE_NAME = "nehaber-v2";
2const OFFLINE_URL = "/offline";
3
4const PRECACHE_URLS = [
5  "/",
6  "/offline",
7  "/assets/images/logo-color.svg",
8  "/favicon.ico",
9];
10
11// Install
12self.addEventListener("install", (event) => {
13  event.waitUntil(
14    caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS))
15  );
16  self.skipWaiting();
17});
18
19// Activate — eski cache'leri temizle
20self.addEventListener("activate", (event) => {
21  event.waitUntil(
22    caches.keys().then((keys) =>
23      Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
24    )
25  );
26  self.clients.claim();
27});
28
29// Fetch — network first, cache fallback
30self.addEventListener("fetch", (event) => {
31  const { request } = event;
32
33  // API, POST, analytics isteklerini cache'leme
34  if (request.url.includes("/api/") || request.method !== "GET" || request.url.includes("/track")) return;
35
36  event.respondWith(
37    fetch(request)
38      .then((response) => {
39        if (response.ok && response.type === "basic") {
40          const clone = response.clone();
41          caches.open(CACHE_NAME).then((cache) => {
42            if (request.url.includes("/haber/") || request.url.includes("/kategori/") ||
43                request.url.includes("/assets/") || request.url.includes("/uploads/") ||
44                request.url.includes("/konu/")) {
45              cache.put(request, clone);
46            }
47          });
48        }
49        return response;
50      })
51      .catch(() => {
52        return caches.match(request).then((cached) => {
53          if (cached) return cached;
54          if (request.mode === "navigate") return caches.match(OFFLINE_URL);
55          return new Response("Offline", { status: 503 });
56        });
57      })
58  );
59});

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.