Sobre esta herramienta
Service worker básico: precachea el shell y sirve cache-first.
sw.js listo para usar: ve el contenido, cópialo o descárgalo con el nombre correcto. Gratis y 100% en tu navegador.
Service worker básico: precachea el shell y sirve cache-first.
const CACHE = 'app-v1';
const ASSETS = ['/', '/index.html', '/styles.css', '/app.js'];
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(ASSETS)));
});
self.addEventListener('fetch', (e) => {
e.respondWith(caches.match(e.request).then((hit) => hit || fetch(e.request)));
});
Service worker básico: precachea el shell y sirve cache-first.
sw.js listo para usar: ve el contenido, cópialo o descárgalo con el nombre correcto. Gratis y 100% en tu navegador.