我有一个通过IIS服务的单页面应用程序(angular- js)。如何防止HTML文件缓存?解决方案需要通过更改index.html或web.config中的内容来实现,因为无法通过管理控制台访问IIS。
我目前正在研究的一些选项是:
IIS是具有.NET Framework 4的7.5版
将以下内容添加到可web.config在Chrome,IE,Firefox和Safari上运行的解决方案中:
web.config
<?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
Cache-Control
no-cache``index.html