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

799
Vistas
How to force reload and clear cache in Typescript?

it recently came to my attention that simply using window.location.reload() is not a hard refresh i.e. cache is cleared along with the refresh. I was then told to use window.location.reload(true) but I discovered this has since been deprecated.

I am not sure how to determine whether or not the cache has been cleared, so I feel that any method that refreshes the page simply won't cut it for what I need to do, as I cannot tell if cache is being cleared.

I have seen various other approaches including window.location.href = window.location.href; but have seen comments saying this does not clear cache.

I have seen people say that using a "POST" method should do the trick, but I am not sure how to implement this into my current code. I am using a MatSnackBar to prompt the user to refresh the page when a newer version of the app has been released. Here is the code for that SnackBar:

showSnackbar(versionFromHTTP: string, appVersion: string): void {
   const httpList = versionFromHTTP.split('.');
   const appList = appVersion.split('.');
   if ((httpList[0] === appList[0]) && (httpList[1] === appList[1])){
     let snack = this.snackBar.open('We\'ve made new updates! Please refresh your browser to get the latest updates.', 'Refresh now');
     snack.onAction().subscribe(() => {
      window.location.href = window.location.href;
    });
   }
   else{
     let snack = this.snackBar.open('We\'ve made new updates - some features may not work correctly until you refresh your browser.', 'Refresh now');
     snack.onAction().subscribe(() => {
      window.location.href = window.location.href;
    });
    }
 }

over 4 years ago · Santiago Trujillo
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