Asp.net mvc 如何抑制标题变化:*使用OutputCacheProfiles时

Asp.net mvc 如何抑制标题变化:*使用OutputCacheProfiles时,asp.net-mvc,asp.net-mvc-3,outputcache,Asp.net Mvc,Asp.net Mvc 3,Outputcache,使用下面给出的任何OutputCacheProfiles <caching> <outputCacheSettings> <outputCacheProfiles> <clear/> <add name="CachingProfileParamEmpty" duration="87" varyByParam="" location="Any"

使用下面给出的任何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>
这反过来会导致浏览器将请求发送到服务器,而不是本地缓存。甚至使用

this.Response.Cache.SetOmitVaryStar(false);
没用。我可以强制不发送头的唯一方法是使用direct属性

[OutputCache(Duration = 60, VaryByParam = "", Location = OutputCacheLocation.Any)]
public ActionResult Index()
我做错了什么?我更喜欢使用CacheProfiles,因为它们可以在web.config中修改


这里发布的标题来自Cassini(服务器:ASP.NET Development Server/10.0.0.0),但我在Windows 2008上的IIS 7中也看到了相同的结果。

对于amit_g来说可能有点晚了,但是对于任何正在寻找答案的人来说,您可以在配置中指定应用程序范围的输出缓存设置,以删除Vary.*响应头

<caching>
  <outputCache omitVaryStar="true" />
  <outputCacheSettings>
    <outputCacheProfiles>
       ...
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

...
请注意,对SetOmitVaryStar使用“true”是省略Vary:*标题的正确值(不是false,它不会忽略它)

使用以下代码对我很有用:

this.Response.Cache.SetOmitVaryStar(true)

<caching>
  <outputCache omitVaryStar="true" />
  <outputCacheSettings>
    <outputCacheProfiles>
       ...
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>