PageSourceSearch

https://repjesus.com/sw.js

js repjesus.com collected 2026-10-03 01:42:30 UTC 2,629 bytes, 94 lines download raw bytes

1importScripts('https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js');
2
3const CACHE_NAME = 'repjesus-pwa-v6';
4const CORE_ASSETS = [
5  '/manifest.json',
6  '/images/logo.png',
7  '/images/logo_rj_192.png',
8  '/images/logo_rj_512.png',
9  '/images/favicon.png'
10];
11
12self.addEventListener('install', (event) => {
13  event.waitUntil(
14    caches.open(CACHE_NAME)
15      .then((cache) => cache.addAll(CORE_ASSETS))
16      .then(() => self.skipWaiting())
17      .catch(() => undefined)
18  );
19});
20
21self.addEventListener('activate', (event) => {
22  event.waitUntil(
23    caches.keys()
24      .then((cacheNames) => Promise.all(
25        cacheNames
26          .filter((cacheName) => cacheName !== CACHE_NAME)
27          .map((cacheName) => caches.delete(cacheName))
28      ))
29      .then(() => self.clients.claim())
30  );
31});
32
33self.addEventListener('fetch', (event) => {
34  const { request } = event;
35
36  if (request.method !== 'GET') return;
37
38  const url = new URL(request.url);
39  if (url.origin !== self.location.origin) return;
40  if (url.pathname.startsWith('/api/') || url.pathname.startsWith('/posts/') || url.pathname.startsWith('/comments/')) return;
41
42  if (request.mode === 'navigate') {
43    event.respondWith(
44      fetch(request)
45        .then((response) => {
46          if (response.ok) {
47            const copy = response.clone();
48            caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
49          }
50          return response;
51        })
52        .catch(async () => {
53          const cached = await caches.match(request);
54          if (cached) return cached;
55
56          const fallback = await caches.match('/');
57          if (fallback) return fallback;
58
59          return new Response('You are offline. Please reconnect and try again.', {
60            status: 503,
61            headers: { 'Content-Type': 'text/plain; charset=UTF-8' }
62          });
63        })
64    );
65    return;
66  }
67
68  if (url.pathname.startsWith('/build/')) {
69    event.respondWith(
70      fetch(request)
71        .then((response) => {
72          if (response.ok) {
73            const copy = response.clone();
74            caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
75          }
76
77          return response;
78        })
79        .catch(() => caches.match(request))
80    );
81    return;
82  }
83
84  event.respondWith(
85    fetch(request).then((response) => {
86      if (response.ok && ['style', 'script', 'image', 'font'].includes(request.destination)) {
87        const copy = response.clone();
88        caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
89      }
90
91      return response;
92    }).catch(() => caches.match(request))
93  );
94});

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.