浏览器不会缓存我的 *.js 文件

Browser will not cache my *.js files

我不明白为什么我的浏览器没有缓存我的 *.js 文件。根据 chrome,它应该是状态为 304,并且 /app_themes/ 文件夹上的 IIS 常见响应 header 在 7 天后设置为 Expire Web Content

request/response header 与 e-tags:

匹配看起来不错

我还缺少其他 IIS 或 Kentico 设置吗?

编辑:我也尝试按照此 answer 在新标签页中打开主页和子页面,但无济于事

但是...我看到它在 Firefox 中有效所以看起来 Chrome 在某些情况下仍然忽略 headers

可能是缓存控件中没有缓存引起的。由于您直接引用该文件,因此您需要在 iis 中更改缓存控制。按照应用主题文件夹的这些说明进行操作。

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache

如果您通过 Kentico 拉取文件(有一个特殊的 url,您将文件部分传递给它,我想不起来了,但是如果您添加 JavaScript 使用JavaScript web part 它将使用这个)我认为然后将 Kentico 设置用于文件缓存并放置正确的 header

你或许可以检查一下settings\ performance \ client side caching

有 2 个设置 "Allow client cache revalidation" 和 "Cache in minutes"。阅读帮助并与他们一起玩