我在iframe中有一个包含另一个html页面的页面。在这个iframe中,我把这个标题标记
<META http-equiv="Pragma" content="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<meta http-equiv="cache-control" content="no-cache" />
但Chrome仍会缓存它,当iframe内容发生变化时,点击f5按钮但Chrome仍然加载缓存版本,而不是新版本。
请告诉我如何通过谷歌Chrome缓存这个iframe。
答案 0 :(得分:3)
在服务器的HTTP响应中设置正确的expiry headers。它们会覆盖您在meta
标记中添加的任何内容。
答案 1 :(得分:2)
适用于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" />
&#13;
我在Chromium bug中发现了这个。 https://bugs.chromium.org/p/chromium/issues/detail?id=28035
答案 2 :(得分:0)
可以忽略元标记。而不是它们,您的服务器应该为缓存控制设置适当的HTTP标头。您还应该设置过期的标头。
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Avoiding_caching
答案 3 :(得分:0)
我发现Chrome浏览器可能会忽略文件中的那些元设置,而使用http响应标头中的缓存设置。我可以通过在web.config中添加此问题来解决IIS中的问题
<system.webServer>
<staticContent>
<clientCache cacheControlMode="NoControl" />
文件仍然被缓存,但是现在我可以根据需要显式排除文件。