You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET项目中Chrome未利用静态文件缓存的问题求助

IIS下.NET项目Chrome静态文件缓存异常排查

在基于IIS的.NET项目中,出现Chrome浏览器忽略部分静态文件缓存指令,但Firefox可正常从缓存加载文件的问题。

web.config相关配置片段

<location path="Scripts">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="100.00:00:00" />
        </staticContent>
    </system.webServer>
</location>

ASPX中静态文件引用示例

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="/Themes/General/css/ant.css" rel="stylesheet" type="text/css"/>
    <link href="../Scripts/vue/Components/css/app2.css" rel="stylesheet" type="text/css" />
</asp:Content>

异常现象

  • Chrome网络流量显示,首次请求响应头已包含预期缓存指令,但后续部分带正确Cache-Control的JS、CSS仍从服务器获取
  • 这些重复请求的资源Etag未变化、Last-Modified时间早于请求时间
  • 页面共180次请求,仅70%从Chrome内存缓存加载

已尝试无效的方案

  • 添加immutable缓存指令
  • 降低cacheControlMaxAge时长
  • 对静态文件进行压缩处理
  • 在多环境、多设备上测试,问题均未解决

恳请提供排查思路或解决方案。

内容的提问来源于stack exchange,提问作者itay regev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 14:43:14