PageSourceSearch

https://you-matter.ai/sw.js

js you-matter.ai collected 2026-10-05 15:08:43 UTC 1,797 bytes, 66 lines download raw bytes

1const CACHE_NAME = 'you-matter-v1';
2const STATIC_ASSETS = [
3  '/',
4  '/index.html',
5  '/manifest.json',
6];
7
8// Install event - cache static assets
9self.addEventListener('install', (event) => {
10  event.waitUntil(
11    caches.open(CACHE_NAME).then((cache) => {
12      return cache.addAll(STATIC_ASSETS);
13    })
14  );
15  self.skipWaiting();
16});
17
18// Activate event - clean up old caches
19self.addEventListener('activate', (event) => {
20  event.waitUntil(
21    caches.keys().then((cacheNames) => {
22      return Promise.all(
23        cacheNames
24          .filter((name) => name !== CACHE_NAME)
25          .map((name) => caches.delete(name))
26      );
27    })
28  );
29  self.clients.claim();
30});
31
32// Fetch event - network first, fallback to cache
33self.addEventListener('fetch', (event) => {
34  // Skip non-GET requests
35  if (event.request.method !== 'GET') return;
36
37  // Skip cross-origin requests except for CDN assets
38  const url = new URL(event.request.url);
39  if (url.origin !== self.location.origin && !url.hostname.includes('cloudfront.net')) {
40    return;
41  }
42
43  event.respondWith(
44    fetch(event.request)
45      .then((response) => {
46        // Clone the response before caching
47        const responseClone = response.clone();
48        caches.open(CACHE_NAME).then((cache) => {
49          cache.put(event.request, responseClone);
50        });
51        return response;
52      })
53      .catch(() => {
54        return caches.match(event.request).then((cachedResponse) => {
55          if (cachedResponse) {
56            return cachedResponse;
57          }
58          // For navigation requests, return the cached index.html
59          if (event.request.mode === 'navigate') {
60            return caches.match('/index.html');
61          }
62          return new Response('Offline', { status: 503 });
63        });
64      })
65  );
66});

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.