PageSourceSearch

https://cdnn.1prime.ru/service-worker.js

js 1prime.ru collected 2026-09-24 08:27:35 UTC 2,521 bytes, 80 lines download raw bytes

1importScripts('/swcachelist.js');
2const cacheName = 'cache-v1';
3const cacheArticlesName = 'cache-articles-v1';
4const cache1 = [
5    '/?offline=1'
6];
7const cacheAll = cache1.concat(cache2);
8
9
10self.addEventListener('install', event => {
11    console.log('%c%s', 'color: green; font-weight:700;', 'Service worker install');
12
13    precache();
14});
15
16self.addEventListener('activate', event => {
17    console.log('%c%s', 'color: green; font-weight:700;', 'Service worker activate');
18    event.waitUntil(
19        caches.keys().then(function(cacheNames) {
20            return Promise.all(
21                cacheNames.filter(function(key) {
22                    if (key !== cacheName && key !== cacheArticlesName) {
23                        console.log('%c%s', 'color: green; font-weight:700;', 'Service worker removing old cache', key);
24                        return true;
25                    }
26                }).map(function(cacheName) {
27                    return caches.delete(cacheName);
28                })
29            );
30        })
31    );
32});
33
34self.addEventListener('fetch', event => {
35    // console.log('### Fetch intercepted for:', event.request);
36    const reqUrl = new URL(event.request.url);
37
38    // if (event.request.method !== 'GET' || reqUrl.host.indexOf('ria.ru') === -1) {
39        // console.log('### WORKER: fetch event ignored.', event.request.method, event.request.url);
40        return;
41    // }
42
43    if (reqUrl.pathname === '/') {
44        event.respondWith(
45            fetch(event.request)
46            .catch(function() {
47                return caches.match('/?offline=1');
48            })
49        );
50    }
51    if (reqUrl.pathname !== '/' && /offline=1$/.test(reqUrl.search)) {
52        event.respondWith(
53            caches.match(event.request).then(function(response) {
54                return response || fetch(event.request);
55            }).catch(function() {
56                return caches.match('/?offline=1');
57            })
58        );
59    }
60
61    if (/\.css$/.test(reqUrl.pathname) || /\.svg$/.test(reqUrl.pathname)) {
62        event.respondWith(
63            caches.open(cacheName).then(function(cache) {
64                return cache.match(event.request).then(function(response) {
65                    return response || fetch(event.request);
66                });
67            })
68        );
69    }
70});
71
72function precache() {
73    caches.open(cacheName).then(function (cache) {
74        cache.addAll(cacheAll);
75    });
76    caches.open(cacheArticlesName).then(function (cache) {
77        cache.addAll(cache3);
78    });
79}
80

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.