IIS 缓存, 更新后前端资源不能更新问题

解决办法:

通常只需要index.html 不缓存即可, 其他文件都是根据index.html 中的引用去加载;

正确的做法是在 站点下增加 web.config 文件, 内容如下:

我这个是因为目录下有个config.js 配置文件, 也不能缓存, 所以加了两个

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="index.html">
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="NoControl" />
            </staticContent>
            <httpProtocol>
                <customHeaders>
                    <add name="Cache-Control" value="no-store" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
    <location path="config.js">
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="NoControl" />
            </staticContent>
            <httpProtocol>
                <customHeaders>
                    <add name="Cache-Control" value="no-store" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
</configuration>

效果:

相关推荐
崔庆才丨静觅35 分钟前
hCaptcha 验证码图像识别 API 对接教程
前端
陌上丨1 小时前
Redis的Key和Value的设计原则有哪些?
数据库·redis·缓存
曹牧1 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
passerby60611 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了1 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅2 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
崔庆才丨静觅2 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
爬山算法2 小时前
Hibernate(90)如何在故障注入测试中使用Hibernate?
java·后端·hibernate
kfyty7252 小时前
集成 spring-ai 2.x 实践中遇到的一些问题及解决方案
java·人工智能·spring-ai
猫头虎2 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven