PageSourceSearch

https://dinellycontabilidade.com.br/serviceworker.js

js dinellycontabilidade.com.br collected 2026-10-08 19:24:16 UTC 1,278 bytes, 36 lines download raw bytes

1'use strict';
2
3const cacheName = 'site-v1'; // Ajuste o nome do cache
4const offlinePage = '/';
5const neverCacheUrls = [/\/wp-admin/, /\/wp-login/, /preview=true/, /\.php$/];
6
7self.addEventListener('install', e => {
8  self.skipWaiting(); // Força substituição imediata
9  e.waitUntil(caches.open(cacheName).then(c => c.addAll(['/', offlinePage])));
10});
11
12self.addEventListener('activate', e => {
13  e.waitUntil(caches.keys().then(keys => Promise.all(keys.map(key => key !== cacheName && caches.delete(key)))));
14  self.clients.claim();
15});
16
17self.addEventListener('fetch', e => {
18  // Ignora wp-admin, cross-origin e métodos não-GET
19  if (!neverCacheUrls.every(reg => !reg.test(e.request.url)) || 
20      new URL(e.request.url).origin !== location.origin ||
21      e.request.method !== 'GET') return;
22
23  e.respondWith(
24    fetch(e.request).then(response => {
25      // Clona apenas respostas válidas (status 200)
26      if (response && response.status === 200) {
27        const resClone = response.clone();
28        caches.open(cacheName).then(cache => cache.put(e.request, resClone));
29      }
30      return response;
31    }).catch(() => {
32      // Fallback para cache ou offline
33      return caches.match(e.request).then(cached => cached || caches.match(offlinePage));
34    })
35  );
36});

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.