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

79
Vistas
Relay information to the service worker on install

I have a PWA with multiple different languages and would like to cache only language specific files on install. I can't find out a way to communicate the language to the service worker during install. Ideas on how I could do it?

My js code to initiate the service worker:

navigator.serviceWorker.register('../service-worker.js', { scope: '/' }).then((reg) => {
    console.log('Service worker registered successfully.', reg);
    registration = reg;
}).catch(function (e) {
    console.error('Error during service worker registration:', e);
});

My code in the service-worker.js:

self.addEventListener('install', function(event) {
    messageAllClients('Event-Install');
    // Perform install steps
    event.waitUntil(
        caches.open(CACHE_NAME).then(function(cache) {
            messageAllClients('Language detected by the service worker: '+language);
            messageAllClients('Pre-caching offline page');
            return cache.addAll(FILES_TO_CACHE);
        })
    );
    self.skipWaiting();
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Variables can be relayed to the service worker during install via GET attributes, as @JeffPosnick pointed out in the comment.

about 4 years ago · Juan Pablo Isaza Denunciar
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