Background
A customer is running our web app. over HTTPS and are running into the (fairly well know) IE8 "file cannot be written to cache" error when they try to view a PDF/Excel/word file because the response contains the HTTP Cache-Control:no-cache
directive. The thing is, it is not our app (or its config) that is adding this directive.
After a bit of investigating I discovered that the IIS7 page output caching feature can also add this header, for example
<caching enabled="false" enableKernelCache="false">
<profiles>
<add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
</profiles>
</caching>
will have the effect of adding Cache-Control:no-cache, private
to response headers.
My Question
But the surprising (IMO) thing is that even when you supposedly disable the feature (see in my config snippet above that enabled="false"
), the response headers are still being sent with Cache-Control:no-cache, private
.
Am I being stupid to be surprised by this (I guess I probably am)?
cache-control: no-cacheThis token is changed on the origin server whenever the resource is updated. When a user returns to a page with a 'no-cache' resource, the client will always have to connect to the origin server and compare the ETag on the cached resource with one on the server.
If specified, HTTP request cache-control headers are ignored for caching decisions. This option available under Web Sites > Traffic management > Caching > Edit the service and set the value of 'Ignore Request Headers' to Yes.
Cache-Control: No-Cache The no-cache directive means that a browser may cache a response, but must first submit a validation request to an origin server.
What effectively got rid of no-cache
for me was adding location="Any"
to the add
element, which instead writes Cache-Control:public
:
<caching enabled="false" enableKernelCache="false">
<profiles>
<add extension=".htm" ... location="Any" />
</profiles>
</caching>
In the absence of the location
attribute, IIS defaults to Cache-Control:no-cache
. Other possible values are Client
, Downstream
, Server
, or ServerAndClient
. Details here.
You're not alone: http://forums.iis.net/t/1152306.aspx
We also had the same problem. I haven't found any documentation about this "feature" so I'm assuming it is a bug.
We decided to just remove the caching tag and use only the clientCache tag instead.
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