Javascript: Clear cache on redirect

caching, cookies, javascript

Solution

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 for reloading static resources (see comment below) would be to append the random number to their URLs server-side by listening for the 'n' query string.

Problem

I can use `location.reload(true)` to refresh the page and refetch the page. I want to redirect the user to a new URL and clear the cache. More specifically, I have a "Clear all cookies" button that redirects the user to the homepage after being clicked. I want the homepage to be refreshed.

Original source

Related problems