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>

效果:

相关推荐
SimonKing6 分钟前
全面解决中文乱码问题:从诊断到根治
java·后端·程序员
shellvon27 分钟前
前端攻防:揭秘 Chrome DevTools 与反调试的博弈
前端·逆向
你三大爷31 分钟前
再探volatile原理
java
β添砖java32 分钟前
案例二:登高千古第一绝句
前端·javascript·css
却尘32 分钟前
Server Actions 深度剖析:这就是个披着 React 外衣的 RPC
前端·rpc·next.js
2301_7816686136 分钟前
Redis 面试
java·redis·面试
郑洁文38 分钟前
基于SpringBoot的天气预报系统的设计与实现
java·spring boot·后端·毕设
沃夫上校1 小时前
MySQL 中文拼音排序问题
java·mysql
南雨北斗1 小时前
Vue 3 修饰符(Modifiers)
前端
Dcs1 小时前
用 Python UTCP 直调 HTTP、CLI、MCP……
java