javascript jquery Ctrl + F5 清除浏览器缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28644209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ctrl + F5 in jquery to clear browser cache
提问by Bugfixer
How to deep refresh window in jquery like you press f5 twice.currently i m using this.
如何像按两次 f5 一样在 jquery 中深度刷新窗口。目前我正在使用它。
<script>
window.onload = function() {
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload();
}
}
</script>
Thanks ! and it should not take much time to refresh. my webpage is in php.
谢谢 !而且刷新时间应该不会太长。我的网页是在 php 中。
回答by RamRaider
I think the reload function can take an argument that forces full refresh. ie:
我认为重新加载函数可以采用强制完全刷新的参数。IE:
window.location.reload(true);
For reference: https://developer.mozilla.org/en-US/docs/Web/API/Location/reload
供参考:https: //developer.mozilla.org/en-US/docs/Web/API/Location/reload
回答by Techie
Ctrl+F5 basically used to refresh the client objects. Whenever we change anything into client scripts then we usually do ctrl+f5 to get the updates. Obviously, no developer want this. Well there is a fix for that.
Ctrl+F5 基本上用于刷新客户端对象。每当我们将任何内容更改为客户端脚本时,我们通常会按 ctrl+f5 来获取更新。显然,没有开发人员想要这个。那么有一个修复。
Seperate your js code into external file and use it in your view.Then, you just need to set a version of JS file where you gonna place it (i.e. in your view)
将您的 js 代码分离到外部文件中并在您的视图中使用它。然后,您只需要设置一个 JS 文件的版本,您将放置它(即在您的视图中)
<script src="path.js?123123" type="text/javascript"></script>
Suppose, path.js is your external JS file and ?123123is basically a temporary versioning of the js file. So, the compiler will always treat it as new file by changing the number.
假设,path.js 是您的外部 JS 文件,?123123基本上是 js 文件的临时版本。因此,编译器将始终通过更改编号将其视为新文件。
Hope this helps
希望这可以帮助

