Javascript: clear cache when redirecting

I can use location.reload(true)to refresh the page and refresh the page. I want to redirect the user to a new URL and clear the cache.

In particular, I have a button "Clear all cookies", which redirects the user to the home page after clicking. I want to refresh the homepage.

+3
source share
2 answers

Do something like:

var loc = window.location.href; // or a new URL
window.location.href = loc + '?n=' + new Date().getTime(); // random number

EDIT: The only option to reload static resources (see comment below) is to add a random number to their server-side URLs while listening to query string n.

+8
source

, clear Javascript.

-1

All Articles