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

352
Visualizações
Best way to avoid Cache Busting ( Need to Hard refresh ) in a react js web application?

i have a react js based web app the problem is every time there is a new deployment it needs to do hard refresh to see the change implemented which is very irritating to the client i could see only two options to fix this

Client Side

Modifying external resources by appending some random stuff like "script.js?ts=timestring"

OR

Server Side

Using Web Pack to create a bundle and modifying the file name from server side by some random stuff

Now is there any other way to do this , also in client side solution i am trying to achieve this

by re appending the loaded scripts to the loading page in index.html

Array.from(document.querySelectorAll('script')).forEach(s => {
                 
                    var fileref = document.createElement('script');
                    fileref.setAttribute("type", "text/javascript");
                    fileref.setAttribute("src", s.src + "?ts=" + Date.now().toString());
                    document.getElementsByTagName("head")[0].appendChild(fileref);
                }  

but this solution is not working because appending the script again causing app to re-render resulting in blank page

please let me know what better can i do in both the cases , whether handle it client side of server side by webpack

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