小编典典

如何禁用通过IIS提供的单页应用程序HTML文件的缓存?

angularjs

我有一个通过IIS服务的单页面应用程序(angular-
js)。如何防止HTML文件缓存?解决方案需要通过更改index.html或web.config中的内容来实现,因为无法通过管理控制台访问IIS。

我目前正在研究的一些选项是:

IIS是具有.NET Framework 4的7.5版


阅读 403

收藏
2020-07-04

共1个答案

小编典典

将以下内容添加到可web.config在Chrome,IE,Firefox和Safari上运行的解决方案中:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

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

</configuration>

这将确保在请求时将Cache-Control标头设置为。no-cache``index.html

2020-07-04