asp.net-mvc – 如何使用OutputCacheProfiles来压缩标头Vary:*
发布时间:2020-12-16 09:15:37 所属栏目:asp.Net 来源:网络整理
导读:使用下面给出的任何OutputCacheProfiles caching outputCacheSettings outputCacheProfiles clear/ add name="CachingProfileParamEmpty" duration="87" varyByParam="" location="Any" / add name="CachingProfileParamNone" duration="87" varyByParam="No
使用下面给出的任何OutputCacheProfiles
<caching> <outputCacheSettings> <outputCacheProfiles> <clear/> <add name="CachingProfileParamEmpty" duration="87" varyByParam="" location="Any" /> <add name="CachingProfileParamNone" duration="87" varyByParam="None" location="Any" /> <add name="CachingProfileParamStar" duration="87" varyByParam="*" location="Any" /> </outputCacheProfiles> </outputCacheSettings> </caching> 标题变化:*始终发送 HTTP/1.1 200 OK Server: ASP.NET Development Server/10.0.0.0 Date: Mon,05 Mar 2012 20:11:52 GMT X-AspNetMvc-Version: 3.0 Cache-Control: public,max-age=87 Expires: Mon,05 Mar 2012 20:13:13 GMT Last-Modified: Mon,05 Mar 2012 20:11:46 GMT Vary: * Content-Type: text/html; charset=utf-8 Content-Length: 5368 Connection: Close 这反过来导致浏览器将请求发送到服务器而不是本地缓存.即使使用 this.Response.Cache.SetOmitVaryStar(false); 没有帮助.我可以强制不发送标头的唯一方法是使用直接属性 [OutputCache(Duration = 60,VaryByParam = "",Location = OutputCacheLocation.Any)] public ActionResult Index() 我究竟做错了什么?我更喜欢使用CacheProfiles,因为可以在web.config中修改它们. 这里发布的标题来自Cassini(服务器:ASP.NET开发服务器/ 10.0.0.0),但我在Windows 2008上的IIS 7中也看到了相同的结果. 解决方法
对于amit_g可能有点迟,但对于寻找答案的其他人,您可以在配置中指定应用程序范围的输出缓存设置以删除Vary.*响应标头.
<caching> <outputCache omitVaryStar="true" /> <outputCacheSettings> <outputCacheProfiles> ... </outputCacheProfiles> </outputCacheSettings> </caching> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-2 – asp.net-mvc2 – 不使用Model的强类型助手
- asp.net-mvc – 如何获取Azure网站上的错误详细信息
- asp.net-mvc – DataAnnotationsModelBinder如何使用自定义
- ASP.NET jQuery 实例13 原创jQuery文本框字符限制插件-Text
- asp.net-mvc – 为什么在HttpGet操作上的mvc属性路由也会影
- asp.net-mvc – ASP.net MVC 3项目文件没有出现在新项目对话
- ASP.NET Core和Angular的RDLC本地报表查看器(> 2.0)
- asp.net – 将DetailsView行组合在一起?
- asp.net-mvc – ASP.NET MVC 5 Html.HiddenFor呈现不正确的
- 如何防止密码和其他敏感信息出现在ASP.NET转储中?
推荐文章
站长推荐
- asp.net-mvc-5 – 在MVC 5的IPasswordStore中,Se
- asp.net-mvc – ASP.NET Web API比ASP.NET MVC有
- ASP.NET:以编程方式更改网站的文化
- asp.net – UserControl有IsPostBack,但是Contro
- asp.net – 如何在文本框的点击事件上附加日历(全
- asp.net-mvc – 建议在开发期间使用nhibernate设
- asp.net-mvc-4 – 具有动态部分视图创建的MVC Aj
- asp.net-web-api – Structure Map无参数构造函数
- 身份验证 – 错误“Membership.Provider”属性必
- ASP.NET Core根据环境切换NLog配置
热点阅读