What’s the alternative to location.reload(true) in JavaScript?

What’s the recommended alternative now that javascript:location.reload(true) is deprecated?

I understand it’s not ideal to reload an Angular Single Page Application, but there’s a scenario in my project where a full page reload is necessary. Previously, I used javascript:location.reload(true) to force a reload from the server, but TSLint flags it as deprecated.

What’s the proper or modern way to handle this now, especially within an Angular app? Is there a clean alternative to force a reload without relying on the deprecated javascript:location.reload(true) syntax?

I’ve come across this a lot over my 7+ years working with Angular. You’re right—javascript:location.reload(true) is now deprecated, since the true parameter (which used to force a server reload) no longer does anything. These days, using window.location.reload() gives you a basic soft reload—like pressing F5.

When I need to make sure the cache is bypassed, I usually add a timestamp to the current URL as a query parameter. It’s a simple trick that keeps things fresh without breaking modern standards—and it works well for most use cases.

Totally agree with @madhurima_sil here. Having worked on several enterprise dashboards, I’ve noticed Angular discourages full page reloads—so we should use them sparingly. That said, when I hit those “must reload from server” moments (logout, permission changes, etc.), I still use:

location.reload();

But if I’m worried about cache issues, instead of javascript:location.reload(true), I lean on smarter strategies—like managing headers or adding version query strings. It’s more reliable and better aligns with how Angular Router handles navigation and route reuse.

Same here—after working on SPAs for a while, I’ve stopped relying on tricks like javascript:location.reload(true) altogether. If I truly need a full reload (like after a major config change), I just use this:

window.location.href = window.location.href;

It gives a clean slate. But honestly, more often than not, I opt for Angular’s built-in reactive features or Router.navigate() to refresh components without losing state. It’s better UX, faster, and more idiomatic to how Angular apps should behave.