【问题标题】:Disabling Output caching through web.config通过 web.config 禁用输出缓存
【发布时间】:2012-09-03 09:34:56
【问题描述】:

我正在尝试巧妙地禁用 WCF 应用程序的输出缓存。 enableOutputCache 属性由于某种原因不起作用,有人可以解释原因,或建议解决方法。

<system.web>      
    <caching>
      <outputCache enableOutputCache="false" enableFragmentCache="false"></outputCache>
      <outputCacheSettings>        
        <outputCacheProfiles>          

        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
  </system.web>

谢谢

【问题讨论】:

  • 您要禁用 WCF 服务还是整个站点的缓存?
  • @Waqar Janjua 我想禁用 WCF 应用程序之一的缓存
  • @athoik 我读过,答案对我不起作用
  • @Costa 你在那个 WCF 应用程序中使用 OutputCache 吗?如果是,请告诉您如何使用该显示您的代码

标签: asp.net wcf outputcache


【解决方案1】:

我知道这是一个老问题,但我想给我两分钱。我实际上需要禁用 SPA 调用的 webapi 服务的缓存,并且在某些版本的 IE 上,它们默认缓存,除非存在 cache-control:no-cache 和类似的标头。我为启用静态资源的浏览器缓存并为所有服务禁用它所做的是根据使用 web-config 的位置添加标头。

<location path="api">
<system.webServer>
  <httpProtocol>
    <customHeaders>
      <add name="Cache-Control" value="no-cache" />
      <add name="Expires" value="-1" />
      <add name="Pragma" value="no-cache" />
    </customHeaders>
  </httpProtocol>
</system.webServer>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 2014-01-15
    • 2011-08-16
    • 1970-01-01
    • 1970-01-01
    • 2016-02-11
    • 1970-01-01
    相关资源
    最近更新 更多