【问题标题】:Is there a way to tell IE to check for newer versions of the web page without configuring the browser itself?有没有办法告诉 IE 在不配置浏览器本身的情况下检查网页的较新版本?
【发布时间】:2021-05-21 09:58:42
【问题描述】:

是否可以从前端/后端代码告诉 IE 进行以下设置?

check newer versions of page every time page is visited

disable IE caching

我尝试添加以下标题:

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="cache-control" content="no-store"> 

但它仍然不起作用,因为我必须设置检查页面是否有新版本的页面(参见第一张图片)。

这是一个 .NET MVC 应用程序

【问题讨论】:

  • 我同意 Athanasios Kataras 的回答。如何检查页面是否被缓存?您可以使用 F12 开发工具检查缓存:i.stack.imgur.com/4ucJj.png。此外,我还找到了一些其他线程,您可以参考。也可以查看this answerthis thread

标签: c# html internet-explorer web-applications


【解决方案1】:

对于 MVC,这实际上非常简单:

Response.Cache.SetCacheability(HttpCacheability.NoCache);  
Response.Cache.AppendCacheExtension("no-store, must-revalidate");
Response.AppendHeader("Pragma", "no-cache"); 
Response.AppendHeader("Expires", "0"); 

元标题完全不可靠:Using <meta> tags to turn off caching in all browsers?

对于 global.asax 中的全局设置:

void Application_PreSendRequestHeaders(Object sender, EventArgs e)
{
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
}

【讨论】:

  • 我已经尝试过这样做,但页面似乎仍在缓存中。 Here 是响应头
  • 您的缓存控制不是无缓存。这是私人的
  • 如何设置缓存控制?
  • 检查全局设置的更新答案
  • 我有tried 但不知何故无法使用Response 对象?
猜你喜欢
  • 2015-08-19
  • 2021-06-17
  • 1970-01-01
  • 2010-12-22
  • 2010-09-26
  • 1970-01-01
  • 1970-01-01
  • 2021-12-04
相关资源
最近更新 更多