[英]Javascript: Clear cache on redirect
I can use location.reload(true)
to refresh the page and refetch the page. 我可以使用location.reload(true)
刷新页面并重新获取页面。 I want to redirect the user to a new URL and clear the cache. 我想将用户重定向到新的URL并清除缓存。
More specifically, I have a "Clear all cookies" button that redirects the user to the homepage after being clicked. 更具体地说,我有一个“清除所有cookie”按钮,在点击后将用户重定向到主页。 I want the homepage to be refreshed. 我希望主页能够刷新。
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. 编辑:重新加载静态资源的唯一选项(请参阅下面的评论)是通过侦听'n'查询字符串将随机数附加到其服务器端的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.