I'm using Azure and IIS 7.5 to serve my web app, I'm not using .NET though.
I'm trying to override the default cache-control value for my static files but it seems that IIS 7.5 adds no-cache no matter what I specify.
My approot/web.config file looks like this:
<?xml version="1.0"?>
<configuration>
<system.webServer>
...
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
...
</system.webServer>
</configuration>
and my response headers are:
Accept-Ranges:bytes
Access-Control-Allow-Origin:*
Cache-Control:no-cache,public,max-age=2592000
Content-Encoding:gzip
Content-Length:4309
Content-Type:application/x-javascript
Date:Mon, 10 Sep 2012 14:42:07 GMT
ETag:"8ccd2f95a8fcd1:0"
Last-Modified:Mon, 10 Sep 2012 13:48:36 GMT
Server:Microsoft-IIS/7.5
Vary:Accept-Encoding
X-Powered-By:ASP.NET
I do have an extra web.config file in one of the subfolders but that doesn't override any clientCache values.
Does anyone know why IIS is prepending no-cache?
Thanks!
Regarding "Without the cache control header the browser requests the resource every time it loads a new(?) page", that doesn't seem to be the case with Google Chrome. It seems to cache those items indefinitely.
The cache-control header has not been set properly or is missing, allowing the browser and proxies to cache content.
Apparently, the output cache needs a location attribute otherwise it will override the staticContent/clientCache setting.
<system.webServer>
...
<caching>
<profiles>
<add extension="*" policy="CacheForTimePeriod" duration="00:01:00" varyByQueryString="*" varyByHeaders="X-Requested-With" location="Any" />
</profiles>
</caching>
...
</system.webServer>
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