通过web.config禁用输出缓存

问题描述 投票:2回答:1

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

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

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

谢谢

asp.net wcf outputcache
1个回答
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>

© www.soinside.com 2019 - 2024. All rights reserved.