通过web.config禁用输出缓存

时间:2012-09-03 09:34:56

标签: asp.net wcf outputcache

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

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

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

由于

1 个答案:

答案 0 :(得分:0)

我知道这是一个老问题,但我想给我两分钱。我实际上需要禁用由SPA调用的webapi服务的缓存,并且在某些版本的IE上,默认情况下缓存它们,除非缓存控制: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>