Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

804
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!