Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
Offline mode for service worker still fetches from server using Chrome offline mode

I am learning about PWAs/service workers and most tutorials either use the offline mode in the application or network tab to toggle the online state. They seem to have no issues yet when I toggle it offline, my service worker is still fetching from the server. The only true way I can get my fallback HTML to load is to stop my express server. I have also tried without any node environment and use live-server as a vscode extension but that too gives me the same result. I have to stop the live-server for it to realize I'm offline.

I've checked my fetch event code in sw.js which matches the tutorial so I don't see any reason for it not to work like others.

// fetch event
self.addEventListener('fetch', function onFetchReceived(evt) {
  // console.log(`Fetch event received`, evt);
  evt.respondWith(
    caches.match(evt.request).then(function fulfilled(cacheResponse) {
      return (
        cacheResponse ||
        fetch(evt.request)
          .then((fetchResponse) => {
            console.log('not found in cache, getting from server');
            return caches.open(dynamicCacheName).then((cache) => {
              cache.put(evt.request.url, fetchResponse.clone());
              return fetchResponse;
            });
          })
          .catch(() => {
            console.log('offline, unable to retrieve from server.');
            return caches.match('/pages/offline.html');
          })
      );
    })
  );
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda