PageSourceSearch

https://www.fernstudi.net/media/templates/site/ontheme/js/serviceworker.js

js fernstudi.net collected 2026-10-02 06:37:05 UTC 4,110 bytes, 105 lines download raw bytes

1/*
2 Copyright 2016 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6     http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
12*/
13
14// Names of the two caches used in this version of the service worker.
15const PRECACHE = 'precache-v5';
16const RUNTIME = 'runtime';
17
18// A list of local resources we always want to be cached.
19const PRECACHE_URLS = [
20    '/media/vendor/fontawesome-free/webfonts/fa-regular-400.woff2',
21    '/media/vendor/fontawesome-free/webfonts/fa-solid-900.woff2',
22    '/media/vendor/fontawesome-free/webfonts/fa-brands-400.woff2'
23];
24
25// The install handler takes care of precaching the resources we always need.
26self.addEventListener('install', event => {
27    event.waitUntil(
28        caches.open(PRECACHE)
29            .then(cache => cache.addAll(PRECACHE_URLS))
30            .then(() => self.skipWaiting())
31    );
32});
33
34// The activate handler takes care of cleaning up old caches.
35self.addEventListener('activate', event => {
36    const currentCaches = [PRECACHE, RUNTIME];
37    event.waitUntil(
38        caches.keys().then(cacheNames => {
39            return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));
40        }).then(cachesToDelete => {
41            return Promise.all(cachesToDelete.map(cacheToDelete => {
42                return caches.delete(cacheToDelete);
43            }));
44        }).then(() => self.clients.claim())
45    );
46});
47
48// The fetch handler intercepts all HTTP requests.
49self.addEventListener('fetch', event => {
50    const request = event.request;
51    const url = request.url;
52
53    if (url.includes('media/') ||
54        url.includes('components/com_jlexcomment/assets') ||
55        url.includes('components/com_jlexreview/assets') ||
56        url.includes('images/') ||
57        url.startsWith('https://cdn.') ||
58        url.includes('components/com_community/')) {
59        event.respondWith(
60            caches.match(request).then(cachedResponse => {
61                if (cachedResponse) {
62                    // Return cached response and update in the background
63                    event.waitUntil(
64                        fetch(request).then(response => {
65                            return caches.open(RUNTIME).then(cache => {
66                                return cache.put(request, response.clone()).then(() => {
67                                    return response;
68                                });
69                            });
70                        })
71                    );
72                    return cachedResponse;
73                }
74                return fetch(request).then(response => {
75                    return caches.open(RUNTIME).then(cache => {
76                        return cache.put(request, response.clone()).then(() => {
77                            return response;
78                        });
79                    });
80                });
81            }).catch(() => {
82                // Optionally, return a fallback image for images
83                if (request.destination === 'image') {
84                    return caches.match('/media/templates/site/ontheme/images/blank.gif');
85                }
86            })
87        );
88    } else {
89        // Use cache-first strategy for other requests
90        /*
91        event.respondWith(
92            caches.match(request).then(cachedResponse => {
93                return cachedResponse || fetch(request).then(response => {
94                    return caches.open(RUNTIME).then(cache => {
95                        return cache.put(request, response.clone()).then(() => {
96                            return response;
97                        });
98                    });
99                });
100            })
101        );
102
103         */
104    }
105});

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.