我已经将IIS7.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>
有几个人提到了这个问题:
有什么建议可以解决这个问题吗?
发布于 2012-01-06 02:56:00
这个问题让我抓狂了一个月。您必须在注册表中禁用IIS缓存,据我所知,这在IIS7中没有任何文档记录,而是一个仍然有效的旧IIS5技巧。您可以将下面的代码转换为.reg文件并导入,也可以导航到该部分并手动添加。我建议在更改此参数后重新启动,我不确定IIS是否在iisreset后重新启动它。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InetInfo\Parameters]
"DisableMemoryCache"=dword:1
发布于 2016-03-24 13:56:09
我之前用Banin's fix在IIS7上解决了这个问题。从那时起,我转到了装有IIS 10的Windows 10,但又遇到了同样的问题。DisableMemoryCache
并没有提供帮助。
然后我禁用了内核缓存,到目前为止,这似乎解决了这个问题(对于截图中的荷兰人,我很抱歉):
发布于 2017-02-04 03:26:03
巴宁的解决方案对我很有效。更改注册表参数并重置IIS后解决了此问题。下面的C#程序(您可以使用LINQPad运行它)将帮助您重现此问题:
using System.IO;
using System.Net;
void Main()
{
var virtualPath = "JunctionPoint/sample.js";
var physicalPath = $@"C:\IISROOT\JunctionPoint\{virtualPath}";
for (int i = 0; i < 100; i++) {
File.WriteAllText(physicalPath, i.ToString());
Console.Write(i + "=");
var client = new WebClient();
string html = client.DownloadString($"http://localhost/{virtualPath}");
Console.WriteLine(html);
if (i.ToString() != html) {
Console.WriteLine("Issue reproduced!!!");
}
}
}
https://stackoverflow.com/questions/6698481
复制相似问题