在 IIS 中仅对网站上的一个特定应用禁用缓存

disable caching in IIS only for one particular app on the website

提问人:Tim 提问时间:11/6/2023 更新时间:11/7/2023 访问量:45

问:

是否可以仅在网站上的一个特定应用程序上禁用 aspx、ashx 和 javascript 文件的缓存,而不能为全局网站禁用缓存?可以在应用的本地 web.config 中完成吗?

IIS 缓存 web-config

评论


答:

0赞 samwu 11/7/2023 #1

您可以尝试将以下内容添加到 web.config 中:

<configuration>
  <location path="index.html">
    <system.webServer>
      <httpProtocol>
        <customHeaders>
          <add name="Cache-Control" value="no-cache" />
        </customHeaders>
      </httpProtocol>
     </system.webServer>
  </location>
</configuration>

评论

0赞 Tim 11/7/2023
位置路径是否将嵌套在下面的指令限制为仅对 index.html 文件有效?
0赞 samwu 11/8/2023
你可以测试它,因为它在这里工作正常,但它不是通用的。