PageSourceSearch

https://cenart.gob.mx/app/sw.js

js cenart.gob.mx collected 2026-10-01 10:44:47 UTC 2,173 bytes, 75 lines download raw bytes

1// Service Worker — Cartelera Cenart
2// Cambia CACHE_VERSION para forzar actualización en todos los clientes
3const CACHE_VERSION = "cenart-v20260927a";
4const CACHE_NAME = CACHE_VERSION;
5
6const PRECACHE = [
7  "./",
8  "./index.html",
9  "./app.js",
10  "./styles.css",
11  "./manifest.webmanifest",
12  "./assets/icon-192.png",
13  "./assets/icon-512.png",
14  "./assets/Copia-de-Logo-Cenart-01-min.png",
15  "./assets/Cenart_desatado_Mesa_de_trabajo_1__1_.png",
16  "./data/data.json",
17  "./data/spaces.json",
18];
19
20// Al instalar: precachear archivos del shell
21self.addEventListener("install", (event) => {
22  event.waitUntil(
23    caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE))
24  );
25  // Activar inmediatamente sin esperar a que cierren las pestañas viejas
26  self.skipWaiting();
27});
28
29// Al activar: borrar caches viejos
30self.addEventListener("activate", (event) => {
31  event.waitUntil(
32    caches.keys().then((keys) =>
33      Promise.all(
34        keys
35          .filter((key) => key !== CACHE_NAME)
36          .map((key) => caches.delete(key))
37      )
38    )
39  );
40  // Tomar control de todas las páginas abiertas inmediatamente
41  self.clients.claim();
42});
43
44// Estrategia: Network-first para data JSON, Cache-first para assets
45self.addEventListener("fetch", (event) => {
46  const url = new URL(event.request.url);
47
48  // Datos: siempre red primero, fallback a cache
49  if (url.pathname.includes("/data/")) {
50    event.respondWith(
51      fetch(event.request)
52        .then((response) => {
53          const clone = response.clone();
54          caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
55          return response;
56        })
57        .catch(() => caches.match(event.request))
58    );
59    return;
60  }
61
62  // Assets y shell: cache-first, actualiza en background
63  event.respondWith(
64    caches.match(event.request).then((cached) => {
65      const networkFetch = fetch(event.request).then((response) => {
66        if (response.ok) {
67          const clone = response.clone();
68          caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
69        }
70        return response;
71      });
72      return cached || networkFetch;
73    })
74  );
75});

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.