Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Service-worker not intercepting first fetch call on initial load

I'm having an issue with my custom service-worker. It doesn't seem to be intercepting the first fetch req when the page is initially loaded (but all fetch reqs afterwards are intercepted correctly). However, if I reload the page, all fetch reqs are intercepted correctly by the service-worker. So the problem only exists on initial load of the page.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

This "first-load" behavior is by design. ServiceWorkers can't intercept the initial requests until they enter the installing state and end with the activated state. One option is to first show users an "Installing..." page, wait for the SW to become active, and then refresh the page. The SW can then serve an "SW activated" page. See example: https://fetch-progress.anthum.com/sw-basic/ - sw-simple.js

// INTERCEPT:  /, /index.html, /index.htm 
if ([scope, scope + 'index.html', scope + 'index.htm'].includes(event.request.url)) {
  event.respondWith(fetch(scope + 'sw-installed.html'))
}
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda