防止在 React spa 应用程序中缓存 index.html

问题描述 投票:0回答:0

我正在使用

React
作为前端和
.net
框架与
IIS
Web 服务器作为后端开发技术。我尝试了几种方法来防止 IIS 缓存
index.html
文件,但它们没有按预期工作,并且
index.html
文件仍然从磁盘缓存中提供服务。 这是我遵循的步骤:

添加元标签到
index.html

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

在网络服务器的
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>

以上没有一个对我有用。知道为什么吗?

感谢您的回复...

reactjs .net iis webserver browser-cache
© www.soinside.com 2019 - 2024. All rights reserved.