1

Perhaps I'm missing something by not wording my Google searches correctly, but I've run into an issue with IIS 8.5 and caching. I have a server set up that by all standards should be serving only static files. Obviously, when a file is changed, the new file should be served up. The issue is that even after a server restart, setting files to immediately expire, didsabling caching, disabling compression, and turning off any other caching feature, the old file with its old timestamp is still being served.

I have the following settings:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering allowHighBitCharacters="false">
                <verbs allowUnlisted="false">
                    <add verb="GET" allowed="true" />
                </verbs>
            </requestFiltering>
        </security>
        <caching enabled="false" enableKernelCache="false" />
        <urlCompression doStaticCompression="false" />
    </system.webServer>
    <location path="" overrideMode="Deny">
        <system.webServer>
        </system.webServer>
    </location>
    <location path="" overrideMode="Allow">
        <system.webServer>
        </system.webServer>
    </location>
</configuration>

The folder in which the files are located has read only permissions. The interesing fact is that if I go to mydomain.com, the old version shows up, but going to newmydomain.com loads the new file (even though they both point to the same IP address).

Nielsvh
  • 1,151
  • 1
  • 18
  • 31

2 Answers2

1

An HTTP client can use the old version of a file if the cache control header(s) sent with the response indicated that the content would not change for a given period of time. It does not matter if the content changed on the server or not.

For example, if the file is sent with the header:

Cache-Control: Max-age=86400

then for 24 hours the client can use the file without contacting the server. If the file changes on the server, the client won't know that the file changed because it won't even make a request to the server.

You can add the must-revalidate cache control attribute to force the client to always make a server request.

Craig S. Anderson
  • 6,966
  • 4
  • 33
  • 46
  • My interest was piqued when clearing the browser's cache, deleting local offline temp files and forcing IE to always refresh from server still resulted in an old page. Is it possible that the file was stored locally even after trying to purge the computer of all copies? Also, 26% of my traffic is with IE, and 46% is with chrome and neither loaded the new content. – Nielsvh Apr 21 '15 at 17:15
  • 2
    I've seen this too - the server for some reason doesn't realize the file has changed. I had to restart the server. – Craig S. Anderson Apr 21 '15 at 19:21
  • There were load balancers between my browser and the page that had caching turned on. Once their cache of my page was deleted, everything worked out. – Nielsvh Oct 20 '15 at 18:50
  • @CraigS.Anderson Did you ever resolve this? We've a IIS8.5 server that started doing this after year in production, no disable-cache settings in place initially and adding them since has not helped. We have to restart site in IIS. Seems like it's a finite/fixed # requests after which it caches and no system log activity correlates with the moment. Reeks of cache settings, but no efforts yet have overcome it. We are about to abandon IIS for this static-content host and switch to Node or some other lightweight HTTP listener process. – storsoc Jan 23 '21 at 22:29
  • @storsoc, it turned out our load balancer had helpfully cached the website. The F5 server was doing its best to carry the load. See https://support.f5.com/csp/article/K13255 for F5-specific information. – Nielsvh Aug 25 '21 at 22:25
0

As noted in my reply to storsoc, our issue was that our load balancer, an F5 server, was trying offload as much as possible from our web servers by caching our site. See K13255: Displaying and deleting HTTP cache entries from the command line (11.x and later) for how to forcefully remove cached entries.

Nielsvh
  • 1,151
  • 1
  • 18
  • 31