强制浏览器重新加载index.htm [英] Force browser to reload index.htm

查看:123
本文介绍了强制浏览器重新加载index.htm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过在浏览器的地址栏中输入URL www.mydomain.com/index.htm或www.mydomain.com来强制浏览器始终加载最新版本的index.htm,并且按下回车键。



我在Chrome中尝试这种方式,并且最新版本的index.htm显然只是加载,当我手动刷新(F5)时,或者URL已经在浏览器的地址栏中,我按回车。

我想我做的事情非常愚蠢,因为当我搜索这个问题时,我能找到的只有解决方案关于如何使浏览器通过将?v = xxxx附加到文件名来重新加载.js和.css文件。但是,这个工作应该如何,甚至不是我正在做这些修改的最新版本的index.htm页面被加载??



我也试过把

 < meta http-equiv =cache-controlcontent =no-cache> 

位于< head> 热媒。但这似乎没有任何效果。

任何帮助将不胜感激!



感谢,Linus

解决方案

好的,显然没有缓存是不够的。
以下是诀窍:

 < meta http-equiv =cache-controlcontent =no -cache,must-revalidate,post-check = 0,pre-check = 0/> 
< meta http-equiv =cache-controlcontent =max-age = 0/>
< meta http-equiv =expirescontent =0/>
< meta http-equiv =expirescontent =Tue,01 Jan 01 1:00:00 GMT/>
< meta http-equiv =pragmacontent =no-cache/>


how can I force a browser to always load the newest version of index.htm when the page is loaded by entering the URL www.mydomain.com/index.htm or just www.mydomain.com in the browser's address field and pressing enter.

I'm trying this in Chrome and the newest version of index.htm is apparently only loaded, when I refresh manually (F5), or when the URL is already in the browser's address field and I press enter.

I guess I am doing something extremely stupid, because when I searched for the issue, all I could find were solutions about how to make a browser reload your .js and .css files by appending ?v=xxxx to the file names. But how should this work, if not even the newest version of index.htm page, in which I am doing these modifiactions, is loaded??

I also tried putting

<meta http-equiv="cache-control" content="no-cache">

in the <head> of index.htm. But this does not seem to have any effect.

Any help would be greatly appreciated!

Thanks, Linus

解决方案

OK, apparently no-cache was not enough. The following does the trick:

  <meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
  <meta http-equiv="cache-control" content="max-age=0" />
  <meta http-equiv="expires" content="0" />
  <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
  <meta http-equiv="pragma" content="no-cache" />

这篇关于强制浏览器重新加载index.htm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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