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?
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.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InetInfo\Parameters]
"DisableMemoryCache"=dword:1
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):
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:
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!!!");
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With