PageSourceSearch

https://dines.paris/sw.js

js dines.paris collected 2026-10-08 07:20:32 UTC 1,114 bytes, 44 lines download raw bytes

1var cacheName = '1.0';
2var offlineUrl = '/offline/';
3
4/**
5 * The event listener for the service worker installation
6 */
7self.addEventListener('install', event => {
8    event.waitUntil(
9        caches.open(cacheName)
10            .then(cache => cache.addAll([
11                offlineUrl
12            ]))
13    );
14});
15
16/**
17 * Is the current request for an HTML page?
18 * @param {Object} event 
19 */
20function isHtmlPage(event) {
21    return event.request.method === 'GET' && event.request.headers.get('accept').includes('text/html');
22}
23/**
24 * Fetch and cache any results as we receive them.
25 */
26self.addEventListener('fetch', event => {
27
28    // Else continue as normal
29    event.respondWith(
30        caches.match(event.request)
31            .then(response => {
32                if (response && !isHtmlPage(event)) {
33                    return response;
34                }
35
36                return fetch(event.request).then(
37                ).catch(error => {
38                    if (isHtmlPage(event)) {
39                        return caches.match(offlineUrl);
40                    }
41                });
42            })
43    );
44});

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.