Prevent google chrome cache html page

风流意气都作罢 提交于 2021-02-08 05:18:24

问题


I have a page with another html page in iframe. In this iframe, i put this header tag

<META http-equiv="Pragma" content="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<meta http-equiv="cache-control" content="no-cache" />

But chrome still cache it, when iframe content changed, hit f5 button but chrome still load cached version, not new version.

Please tell me how to pevent google chrome cache this iframe.


回答1:


Set the correct expiry headers in the HTTP response from your server. They override anything you've put in meta tags.




回答2:


This works in Chrome:

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

I found this in a Chromium bug. https://bugs.chromium.org/p/chromium/issues/detail?id=28035




回答3:


Meta tags can be ignored. Instead of them your server should set appropriate HTTP headers for cache control. You should also set the Expired header.

https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Avoiding_caching




回答4:


I found that Chrome may ignore those meta settings in the file in favor of the cache settings in http response header. I was able to fix this issue in IIS by adding this in my web.config

<system.webServer>
  <staticContent>
    <clientCache cacheControlMode="NoControl" />

Files still get cached but now I can explicitly exclude a file if I need to.



来源:https://stackoverflow.com/questions/11066336/prevent-google-chrome-cache-html-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!