I have some static content with cache control Max-Age
headers attached to it so clients will cache the static content. However, IIS 7.5 still sends this header out when there are error responses advising the client to cache this.
The has the negative effect that some proxies will then cache that error response. I could Vary: Accept,Accept-Encoding
but this doesn't really address the root problem of Max-Age
going out on error responses.
The current relevant IIS web.config
section is:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
Is there a way so I can make it so we don't tell clients or proxies to cache 400/500 error codes?
Best Answer
I created a rudimentary test "suite".
When I run the tests with a minimal Web.config on IIS 7.0 (Integrated pipline mode on .NET 4.0) everything passes; the test file's
Cache-Control
response header is set toprivate
when it's request'sAccept
header doesn't match the file'sContent-Type
.This leads me to believe that you have some module interrupting IIS's static caching routine or IIS 7.0 and 7.5 differ here.
Here are the files I used (sans
some-script.js
since its just an empty file):Web.Config:
test.html: