如何防止 IIS 7.5 缓存符号链接内容?
我已经设置 IIS 7.5 来静态提供一些文件,其中一些文件实际上是符号链接(由 mklink
创建)。
即使我禁用了内核和用户缓存,这些文件似乎仍被 IIS 以某种方式缓存。文件修改后,IIS 仍然提供旧版本服务。
为了确保它不是由 ASP.NET 引起的,我创建了一个专用的非托管 AppPool。我还检查过这些文件没有被浏览器缓存。
我的 web.config 如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
<caching enabled="false" enableKernelCache="false" />
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</configuration>
有几个人提到这个问题:
有任何提示如何解决此问题吗?
I have set up IIS 7.5 to statically serve some files, and some of these files are actually symbolic links (created by mklink
).
Even if I disabled both kernel and user caching, these files seems to be cached somehow by IIS. And IIS is still serving old versions after the files are modified.
To be sure that it is not caused by ASP.NET, I've created a dedicated unmanaged AppPool. I have also checked that these file are not cached by browsers.
My web.config is following:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
<caching enabled="false" enableKernelCache="false" />
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</configuration>
There are several people mentioning this problem:
Any hints how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题让我发疯了大约一个月。您必须在注册表中禁用 IIS 缓存,据我所知,这在 IIS 7 的任何地方都没有记录,而是一个仍然有效的旧 IIS 5 技巧。您可以将以下内容转换为 .reg 文件并导入,也可以导航到该部分并手动添加。我建议更改此参数后重新启动,我不确定 IIS 是否会在 iisreset 后重新启动它。
This problem drove me nuts for like a month a while back. You have to disable IIS caching in the registry, as far as I know this isn't documented anywhere for IIS 7 but instead is an old IIS 5 trick that still works. You can either turn the below into a .reg file and import it or you can just navigate to the section and add it manually. I recommend rebooting after changing this parameter, I'm not sure if IIS picks it up after just an iisreset.
我之前能够通过 Banin 的修复在 IIS7 上修复此问题。从那时起,我已经迁移到带有 IIS 10 的 Windows 10,并再次遇到了同样的问题。
DisableMemoryCache
没有帮助。然后我禁用了内核缓存,目前看来,这似乎解决了问题(我对屏幕截图中的荷兰语感到抱歉):
I was previously able to fix this issue on IIS7 with Banin's fix. Since then, I have moved to Windows 10 with IIS 10, and suffered the same problem again.
DisableMemoryCache
did not help.I then disabled kernel caching, and for now, that seems to fix the issue (I'm sorry for the Dutch in the screenshot):
巴宁的解决方案对我有用。更改注册表参数并重置 IIS 后问题得到解决。下面的 C# 程序(您可以使用 LINQPad 来运行它)将帮助您重现该问题:
Banin's solution worked for me. The issue was resolved after changing registry parameter and resetting IIS. The C# program below (you can use LINQPad to run it) will help you reproduce the issue: