PageSourceSearch

https://dream-tv.vercel.app/sw.js

js dream-tv.vercel.app collected 2026-10-03 06:47:20 UTC 2,453 bytes, 79 lines download raw bytes

1const CACHE_NAME = 'dream-tv-v2';
2const DYNAMIC_CACHE = 'dream-tv-dynamic-v2';
3const URLS_TO_CACHE = [
4  '/',
5  '/index.html',
6  'https://cdn.tailwindcss.com',
7  'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap'
8];
9
10self.addEventListener('install', (event) => {
11  event.waitUntil(
12    caches.open(CACHE_NAME)
13      .then((cache) => {
14        return cache.addAll(URLS_TO_CACHE);
15      })
16  );
17  self.skipWaiting();
18});
19
20self.addEventListener('activate', (event) => {
21  const cacheWhitelist = [CACHE_NAME, DYNAMIC_CACHE];
22  event.waitUntil(
23    caches.keys().then((cacheNames) => {
24      return Promise.all(
25        cacheNames.map((cacheName) => {
26          if (cacheWhitelist.indexOf(cacheName) === -1) {
27            return caches.delete(cacheName);
28          }
29        })
30      );
31    })
32  );
33  self.clients.claim();
34});
35
36self.addEventListener('fetch', (event) => {
37  // Skip cross-origin requests, like those for Google Analytics.
38  if (!event.request.url.startsWith(self.location.origin) && !event.request.url.startsWith('https://')) {
39    return;
40  }
41
42  event.respondWith(
43    caches.match(event.request)
44      .then((response) => {
45        if (response) {
46          // Stale-while-revalidate pattern
47          fetch(event.request).then(networkResponse => {
48            if (networkResponse && networkResponse.status === 200) {
49              const responseToCache = networkResponse.clone();
50              caches.open(DYNAMIC_CACHE).then(cache => {
51                 cache.put(event.request, responseToCache);
52              });
53            }
54          }).catch(err => console.log('Network request failed, using cache'));
55          
56          return response;
57        }
58
59        return fetch(event.request).then((networkResponse) => {
60          if (!networkResponse || networkResponse.status !== 200 || networkResponse.type !== 'basic') {
61            return networkResponse;
62          }
63
64          const responseToCache = networkResponse.clone();
65          caches.open(DYNAMIC_CACHE)
66            .then((cache) => {
67              cache.put(event.request, responseToCache);
68            });
69
70          return networkResponse;
71        }).catch(() => {
72          // If network fetch fails (offline) and no cache, and it's a navigation request, could return a fallback HTML here
73          if (event.request.mode === 'navigate') {
74            return caches.match('/index.html');
75          }
76        });
77      })
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.