window.location.reload 清除缓存 [英] window.location.reload with clear cache

查看:109
本文介绍了window.location.reload 清除缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 JavaScript 重新加载页面,但我也想清除缓存,因此在页面刷新时,该页面包含来自服务器的所有内容的最新版本.
除 IE 外的其他浏览器未获取最新内容.

I want to reload a page using JavaScript but I want to clear cache too, so on page refresh the page has latest versions of everything from server.
Other browsers except IE are not getting latest content.

IE9 有什么解决方案吗?

Any solution for IE9?

推荐答案

reload() 应该接受一个参数,告诉它进行硬重新加载,即忽略缓存:

reload() is supposed to accept an argument which tells it to do a hard reload, ie, ignoring the cache:

location.reload(true);

我不能保证它的可靠性,您可能需要进一步调查.

I can't vouch for its reliability, you may want to investigate this further.

编辑(2021):该参数从未标准化,并且在更现代的浏览器中已被弃用和删除.每季度添加一条评论来描述这一事实将无济于事.

Edit (2021): the parameter was never standardised and has been deprecated and removed in more modern browsers. Adding a comment every quarter describing this fact will not help.

这篇关于window.location.reload 清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆