19

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?

Michael
  • 8,362
  • 6
  • 61
  • 88
TN.
  • 18,874
  • 30
  • 99
  • 157

3 Answers3

23

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
Banin
  • 246
  • 3
  • 3
3

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 dialog box screenshot

Michael
  • 8,362
  • 6
  • 61
  • 88
Grimace of Despair
  • 3,436
  • 26
  • 38
  • Note that OP already disabled Kernel Caching (`enableKernelCache="false"`). Unfortunately, this solution does not work for me on IIS 10. Same result. – IluTov Oct 09 '17 at 11:14
1

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!!!");
    }
  }
}
Michael
  • 8,362
  • 6
  • 61
  • 88
Raman Zhylich
  • 3,537
  • 25
  • 23