PageSourceSearch

https://royalturkish.com/sw.js

js royalturkish.com collected 2026-10-08 09:05:57 UTC 1,959 bytes, 51 lines download raw bytes

1const CACHE_NAME = 'rts-v3';
2const OFFLINE_URL = '/offline.html';
3// NOTE: do NOT precache /css/style.css (unversioned) — pages load it as /css/style.css?v=NN.
4// Caching the bare URL risked serving a stale stylesheet. Versioned CSS is fetched network-first.
5const PRECACHE = [
6  '/',
7  '/offline.html',
8  '/images/logo.png',
9  '/images/icon-192.png',
10];
11
12self.addEventListener('install', e => {
13  e.waitUntil(
14    caches.open(CACHE_NAME).then(cache => cache.addAll(PRECACHE)).then(() => self.skipWaiting())
15  );
16});
17
18self.addEventListener('activate', e => {
19  e.waitUntil(
20    caches.keys().then(keys =>
21      Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
22    ).then(() => self.clients.claim())
23  );
24});
25
26self.addEventListener('fetch', e => {
27  if (e.request.method !== 'GET') return;
28  const url = new URL(e.request.url);
29
30  // Skip Firebase, Firestore, analytics, CDN requests
31  if (!url.origin.includes('royalturkish.com') && !url.origin.includes('royal-turkish-schools')) return;
32
33  // Ses/video ve aralık (Range) isteklerine dokunma: Safari'de SW üzerinden geçen kısmi istekler
34  // kitap ses kayıtlarını yarıda kesiyordu (07.10). Tarayıcı doğrudan sunucuya gitsin.
35  if (e.request.headers.has('range') || e.request.destination === 'audio' || e.request.destination === 'video' || /\.(mp3|m4a|mp4|webm)$/i.test(url.pathname)) return;
36
37  e.respondWith(
38    fetch(e.request)
39      .then(res => {
40        // Cache HTML pages and static assets
41        if (res.ok && (e.request.destination === 'document' || e.request.destination === 'style' || e.request.destination === 'image')) {
42          const clone = res.clone();
43          caches.open(CACHE_NAME).then(cache => cache.put(e.request, clone));
44        }
45        return res;
46      })
47      .catch(() =>
48        caches.match(e.request).then(cached => cached || (e.request.destination === 'document' ? caches.match(OFFLINE_URL) : Response.error()))
49      )
50  );
51});

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.