0

On Windows 10 using IIS as the Web Server, it seems that directories created under wwwroot with the mklink command at some point stop seeing changes made to files in that directory. The following is what I did to test this out:

I created a directory C:\test and then created a symlink to that directory on C:\inetpub\wwwroot using the following DOS command:

mklink /D C:\inetpub\wwwroot\test C:\test

Then, in the C:\test directory, I created a small HTML file called test.html with the following content:

<html>
<body>
This is test 1
</body>
</table>

Then, on the same computer, I open Microsoft Edge and go to the following page:

http://localhost/test/test.html

It works and displays This is a test 1 as is expected. Then I modify the file in Notepad to show This is test 2. Again it works. However, after a few iterations, in my case up to This is test 5, the browser stops showing the updated file. It just shows This is test 4. I can change the file to display numbers 6, 7, 8, etc, but the browser stays at This is test 4.

At first I thought it was a caching issue but I turned off caching in IIS and the problem persists. I even rebooted after disabling caching and it starts working again for a few iterations and then stops updating again.

If you create directory test under C:\inetpub\wwwroot so test is NOT a symlink and go through the above exercise then it works perfectly, just like it is supposed to.

To get around this issue, I created a batch file makelink.bat with the following commands:

rmdir C:\inetpub\wwwroot\test
mklink /D C:\inetpub\wwwroot\test C:\test
timeout 300
makelink

This forces a recreation of the symlink every five minutes which causes the correct info to show up again in a browser for a few more iterations. Obviously, this is not an ideal solution.

Is this a bug in Windows 10 or am I doing something wrong?

user1828108
  • 447
  • 1
  • 4
  • 11
  • Perhaps the modified time of the symlink folder is not updated so IIS does not bother reading the file again? NTFS can wait several minutes after a handle is closed before times are updated. Try Process Monitor... – Anders Jan 23 '22 at 21:20
  • Windows Explorer seems to show the updated time, but maybe IIS is not reading that time. Regardless, I don't know what I need to do to make IIS see that the file is updated, even if that was case. – user1828108 Jan 24 '22 at 01:28

1 Answers1

0

You can try to disable IIS caching in the registry, then reboot and try again.

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\InetInfo\Parameters\DisableMemoryCache (REG_DWORD)

When this registry key is set to a nonzero value, the file cache is disabled, you can set it to 1.

samwu
  • 3,857
  • 3
  • 11
  • 25