浏览器不会反映在 html 文件中所做的更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15010109/
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
Browsers won't reflect changes made in html file
提问by malutan.mircea
I am developing a web site and just ran into a very disturbing problem. My code won't refresh in any browser, meaning not just Internet Explorer but also Google Chrome and Firefox.
我正在开发一个网站,但遇到了一个非常令人不安的问题。我的代码不会在任何浏览器中刷新,这意味着不仅是 Internet Explorer,还有 Google Chrome 和 Firefox。
The thing is, in a previous version of the HTML file, I have had a div with a link in it (<a href="">Send request</a>
). Today, I have changed that link into a paragraph (<p>Send request<p>
).
问题是,在以前版本的 HTML 文件中,我有一个带有链接的 div ( <a href="">Send request</a>
)。今天,我把那个链接改成了一个段落(<p>Send request<p>
)。
When I load my page, it still displays the link. When I commented out the paragraph and reloaded the page, there was no link and my paragraph was checked out. I checked the source file in Chrome and yes, the source file is correct. However, the browser still displays a link that doesn't exist, and deleting the browser history didn't help.
当我加载我的页面时,它仍然显示链接。当我注释掉段落并重新加载页面时,没有链接并且我的段落被签出。我在 Chrome 中检查了源文件,是的,源文件是正确的。但是,浏览器仍然显示不存在的链接,删除浏览器历史记录也无济于事。
Any ideas?
有任何想法吗?
回答by user1428716
You can try out the following
您可以尝试以下方法
- Clear the cache of the browser.
- Do a clean build of the Webapp
- 清除浏览器的缓存。
- 对 Webapp 进行干净的构建
OR
或者
Open the Browser in InCognito or Private Browsing Mode
在隐身或隐私浏览模式下打开浏览器
OR
或者
Try to put a meta tag in your HTML
尝试在您的 HTML 中放置一个元标记
<meta http-equiv="pragma" content="no-cache" />
回答by Vikas Raturi
The problem might be due to your Browser caching the HTML Page. This problem may be avoided by -
问题可能是由于您的浏览器缓存了 HTML 页面。这个问题可以通过以下方式避免 -
Clearing the Cache of your Browser
Try using a false query such as mypage.html?random=6 This method cause the browser to reload he page entirely on a GET request.
Use meta tags as below
<meta http-equiv="pragma" content="no-cache" />
This sometimes is accompanied by another meta in addition as follows
<meta http-equiv="expires" content="-1" />
It has been observed that sometimes both the above tags are ignored in IE. The suggested workaround is to use the tag twice, i.e. at start as well end of page. This is due to reason because first a 64K buffer is filled by browser on page load. if the buffer is not filled, the "pragma" is simply ignored. Placing this at end of document facilitates no-caching.
清除浏览器的缓存
尝试使用错误查询,例如 mypage.html?random=6 此方法会导致浏览器完全根据 GET 请求重新加载页面。
使用元标记如下
<meta http-equiv="pragma" content="no-cache" />
这有时还伴随着另一个元数据,如下所示
<meta http-equiv="expires" content="-1" />
据观察,有时上述标签在 IE 中都会被忽略。建议的解决方法是使用该标签两次,即在页面的开头和结尾。这是由于浏览器在页面加载时首先填充了 64K 缓冲区的原因。如果缓冲区没有被填满,“pragma”就会被忽略。将其放在文档末尾有助于无缓存。
回答by José Cabo
If you are using Firefox install the extension called web developer.
如果您使用 Firefox,请安装名为web developer的扩展。
Then go to Disable -> Disable Cache -> Disable entire cache.
然后转到禁用-> 禁用缓存-> 禁用整个缓存。
If you are using Chrome or Chrommium open developer firebug (f12) then go settings (bottom, right) and enable checkbox with text "Disable cache".
如果您使用 Chrome 或 Chrommium open developer firebug (f12),则转到设置(底部,右侧)并启用带有文本“禁用缓存”的复选框。
In both cases remember to recharge the web page with control+shift+R (various times :P).
在这两种情况下,请记住使用 control+shift+R(不同时间:P)为网页充电。
And remember to disable this options when you've end your work.
并记住在您结束工作时禁用此选项。
回答by JerryHuang.me
Another trick is to add a false query behind your html tag and force the browser to fetch a new page.
另一个技巧是在你的 html 标签后面添加一个错误的查询并强制浏览器获取一个新页面。
For example:
例如:
MySite.html -> MySite.html?q=1, MySite.html?q=2, MySite.html?q=3, and so forth.
MySite.html -> MySite.html?q=1、MySite.html?q=2、MySite.html?q=3,依此类推。
As others have mentioned, it seems to be caching is enabled on your host provider.
正如其他人所提到的,您的主机提供商似乎启用了缓存。