PageSourceSearch

https://ashtadhyayi.com/service_worker.js

js ashtadhyayi.com collected 2026-10-02 16:32:23 UTC 2,665 bytes, 95 lines download raw bytes

1// AutoGenerated Sun Aug 16 19:22:42 PDT 2026
2var serviceWorkerAppShellCacheId = "ashtadhyayi.com-cache-1786933362";
3
4// const PRECACHE_ASSETS = ['/fonts/', '/images/', '/kridanta/'];
5
6self.addEventListener('install', (e) => {
7  self.skipWaiting();
8  e.waitUntil(caches.open(serviceWorkerAppShellCacheId).then(
9      function (cache) {
10        return cache.addAll([
11          '/',
12          'index.php'
13        ]);
14      }));
15});
16
17self.addEventListener('activate', (e) => {
18  e.waitUntil(
19    Promise.all([
20      clients.claim(),
21      caches.keys().then(function (keyList) {
22        return Promise.all(keyList.map((key) => {
23          if (key !== serviceWorkerAppShellCacheId) {
24            return caches.delete(key);
25          }
26        }));
27      })
28    ])
29  );
30});
31
32self.addEventListener('fetch', (e) => {
33  /* Bypass non-GET requests */
34  if (e.request.method != 'GET') {
35    e.respondWith(fetch(e.request));
36    return;
37  }
38  /* Bypass cache for github, prakriya, analytics requests */
39  var networkOnlyUrls = [
40    'sanskritworld',
41    'githubusercontent',
42    'jsdelivr',
43    'jsondata',
44    'drive',
45    'unsplash',
46    'api.github.com',
47    'googletagmanager',
48    'vidyut_prakriya_bg'
49  ];
50
51  for (var i = 0; i < networkOnlyUrls.length; ++i) {
52    var url = networkOnlyUrls[i];
53    if (e.request.url.indexOf(url) >= 0) {
54      e.respondWith(fetch(e.request));
55      return;
56    }
57  }
58
59
60  var permittedExtensions = [".pdf", ".php", ".css", ".js", ".png", ".svg", ".jpeg", ".jpg", ".mp3",
61    ".m4a", ".ico", ".woff", ".woff2", ".txt", ".json", ".html"];
62
63  const pathname = new URL(e.request.url).pathname;
64
65  const cacheKey = permittedExtensions.find(ext => pathname.endsWith(ext)) ? e.request.url : "/";
66
67  // Cache first. Do not add "ignoresearch" here. Causes too may problems.
68  e.respondWith(
69    caches.match(cacheKey)
70      .then(async (response) => {
71        if (response) {
72          return response;
73        } else {
74          const result = await fetch(e.request);
75          if (result.status === 200) {
76            var resultToCache = result.clone();
77            caches.open(serviceWorkerAppShellCacheId).then(function (cache) {
78              cache.put(cacheKey, resultToCache);
79            });
80          }
81          return result;
82        }
83      })
84      .catch(async (error) => {
85        return caches.open(serviceWorkerAppShellCacheId).then(function (cache) {
86          return cache.match('/');
87        });
88      }));
89});
90
91/**
92 * Storage-test:https://storage-quota.glitch.me/
93 * IndexedDB (Localforage) for data.
94 * CacheStorage for pages
95 */

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.