PageSourceSearch

https://favsync.com/sw.js

js favsync.com collected 2026-09-24 13:33:45 UTC 2,336 bytes, 77 lines download raw bytes

1const CACHE_NAME = 'favsync-v5';
2const ASSETS = [
3  './',
4  './index.html',
5  './public.html',
6  './features.html',
7  './features.css',
8  './features.js',
9  './js/script.js',
10  './js/public.js',
11  './css/styles.css',
12  './css/public.css',
13  './manifest.json',
14  './img/logo_pwa.png'
15];
16
17// Install event: cache assets
18self.addEventListener('install', event => {
19  self.skipWaiting(); // Force active immediately
20  event.waitUntil(
21    caches.open(CACHE_NAME)
22      .then(cache => {
23        return cache.addAll(ASSETS);
24      })
25  );
26});
27
28// Activate event: clean up old caches
29self.addEventListener('activate', event => {
30  event.waitUntil(
31    caches.open(CACHE_NAME).then(cache => {
32      // Clean up previous SW path if cached
33      cache.delete('./js/sw.js');
34    }).catch(() => {})
35    .then(() => caches.keys())
36    .then(cacheNames => {
37      return Promise.all(
38        cacheNames.map(cache => {
39          if (cache !== CACHE_NAME) {
40            return caches.delete(cache);
41          }
42        })
43      );
44    }).then(() => self.clients.claim())
45  );
46});
47
48// Network-first strategy: Always try network first to prevent caching issues during updates
49self.addEventListener('fetch', event => {
50  // Only handle GET requests and local/same-origin resources to avoid CORS issues
51  if (event.request.method !== 'GET') return;
52  
53  // Skip cross-origin requests like Supabase or Google Fonts
54  if (!event.request.url.startsWith(self.location.origin)) return;
55
56  event.respondWith(
57    fetch(event.request)
58      .then(networkResponse => {
59        // If valid response, clone and update cache
60        if (networkResponse && networkResponse.status === 200 && networkResponse.type === 'basic') {
61          const responseToCache = networkResponse.clone();
62          caches.open(CACHE_NAME).then(cache => {
63            cache.put(event.request, responseToCache);
64          });
65        }
66        return networkResponse;
67      })
68      .catch(async () => {
69        // Fallback to cache if network is offline/fails
70        const cachedResponse = await caches.match(event.request);
71        if (cachedResponse) return cachedResponse;
72        
73        // If no cache, return a basic error response instead of undefined
74        return new Response('Offline and not in cache', { status: 503, statusText: 'Service Unavailable' });
75      })
76  );
77});

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.