PageSourceSearch

https://totaldestroyer.fun/sw.js

js totaldestroyer.fun collected 2026-10-02 01:54:17 UTC 2,333 bytes, 80 lines download raw bytes

1const CACHE_NAME = '3d-flags-cache-v3';
2const MEDIA_CACHE = '3d-media-cache-v1';
3
4// Встановлення
5self.addEventListener('install', (event) => {
6  event.waitUntil(
7    Promise.all([
8      caches.open(CACHE_NAME),
9      caches.open(MEDIA_CACHE)
10    ])
11  );
12  self.skipWaiting();
13});
14
15// Активація
16self.addEventListener('activate', (event) => {
17  event.waitUntil(
18    caches.keys().then(cacheNames => {
19      return Promise.all(
20        cacheNames.map(cacheName => {
21          // Видаляємо старі версії кешів
22          if (cacheName !== CACHE_NAME && cacheName !== MEDIA_CACHE) {
23            return caches.delete(cacheName);
24          }
25        })
26      );
27    })
28  );
29  self.clients.claim();
30});
31
32// Стратегія кешування
33self.addEventListener('fetch', (event) => {
34  const { request } = event;
35  const url = new URL(request.url);
36  
37  // Ігноруємо не-HTTP запити (chrome-extension, chrome://, тощо)
38  if (!url.protocol.startsWith('http')) {
39    return;
40  }
41  
42  // Пропускаємо API запити
43  if (url.pathname.includes('/api/')) {
44    return;
45  }
46  
47  // Пропускаємо навігацію
48  if (request.mode === 'navigate') {
49    return;
50  }
51  
52  // Кешуємо ВСІ медіа файли
53  const isMedia = 
54    url.pathname.match(/\.(fbx|glb|gltf|png|jpg|jpeg|webp|hdr|svg)$/i) ||
55    url.pathname.includes('/models/') ||
56    url.pathname.includes('/textures/') ||
57    url.pathname.includes('/environments/') ||
58    url.pathname.includes('/uploads/');
59  
60  if (isMedia) {
61    event.respondWith(
62      caches.open(MEDIA_CACHE).then(cache => {
63        return cache.match(request).then(response => {
64          // Якщо є в кеші - повертаємо
65          if (response) {
66            return response;
67          }
68          // Якщо немає - завантажуємо і кешуємо
69          return fetch(request).then(response => {
70            // Кешуємо тільки успішні відповіді
71            if (response && response.ok && response.status === 200) {
72              cache.put(request, response.clone());
73            }
74            return response;
75          });
76        });
77      })
78    );
79  }
80});

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.