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

298
Visualizações
React Cache Busting - Reloading the Page After Clearing Cache

I have been researching the topic for several days now and have yet to find a pure js solution that works. After clearing the browser cache (cache busting), is there a way in JS / React to reload the page with the new version?

At the moment, after clearing the cache the users have to close the browser and visit the site again before they can see the new version... as the cache is only cleared after it is already loaded. Manually refreshing the page does not work either - the browser must be closed.

I have seen several suggestions to use window.location.reload(true), but that does not seem to work anymore on modern browsers.

I would prefer to be able to do it purely on the client side, if possible.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When you register service worker in index.js file.

serviceWorkerRegistration.register();

The service worker starts working. But based on a problem, it can not activate itself. :)

enter image description here

To solve this problem, you can overwrite the service-worker.js file .

Instead of this code

self.addEventListener('message', (event) => {
if (event.data && event.data.type === 'SKIP_WAITING') {
    self.skipWaiting();
}

});

You can follow this method

self.addEventListener('install', event => event.waitUntil(self.skipWaiting()));
self.addEventListener('activate', event => event.waitUntil(self.clients.claim()));
about 4 years ago · Juan Pablo Isaza 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