3

I have implemented static content caching on the Images folder in our application by creating the below Web.config file in the Images folder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
        </staticContent>
    </system.webServer>
</configuration>

I believe this has the effect of caching all the images on the client side for 365 days.

I tested the caching using fiddler by examining the response headers.

Initially, I was able to see headers for all files in the Images folder to have a max-age value of

Cache-Control: max-age=31536000

However, suddenly today I was not able to see it.

There have been no changes to the code or config.

Can someone please shed some light on why this is happening and how I can better test if caching is correctly working?

Thanks, Rashmi

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Rashmi Pandit
  • 23,230
  • 17
  • 71
  • 111
  • I wonder if clearing your local cache helps? i.e. Are you sure that you are actually getting a fresh content header? perhaps your images are simply cached. – That Realty Programmer Guy Jun 16 '14 at 21:21
  • I tried clearing the cache, and also redownloading by doing a Ctrl + F5 in IE. Then I check by doing simply F5. I was able to get correct headers by following all these steps earlier. But suddenly, I just don't see the max-age anymore. – Rashmi Pandit Jun 16 '14 at 22:48
  • Yes, that should have done it! How strange, I wonder what the cause could be. Have you already tried putting a minor change (like a space) in the web config and re-uploading it? I think you'd have to then view a page on your app for the ASP.NET server to scan the config again. If you temporarily get the right header after that maybe you'd know more about the problem. It seems JSFiddle hasn't put any updates on their side lately either. So strange. – That Realty Programmer Guy Jun 16 '14 at 23:09
  • If you have an example url I could check for headers from wget and/or a network library. – That Realty Programmer Guy Jun 16 '14 at 23:11
  • @GaretClaborn Yes, I tried to make changes to web.config. And also tried to restart the web site as its hosted on my machine. Unfortunately, I can't provide any url as its locally hosted. – Rashmi Pandit Jun 17 '14 at 04:29
  • Have you tried this http://stackoverflow.com/questions/10653549/iis-7-5-and-images-not-being-cached – Jitendra Pancholi Jul 09 '14 at 10:56
  • Also you can check this http://serverfault.com/questions/448942/why-is-iis-7-5-flushing-file-cache-very-often – Jitendra Pancholi Jul 09 '14 at 10:58

0 Answers0