1

I have ASP.NET MVC action filter that sets the cache-control header of the response. It all works fine except when I publish it to the web server.

When I'm running it through localhost I get the following :

Cache-Control:public, max-age=172800
Connection:Close
Content-Length:15057
Content-Type:application/pdf
Date:Thu, 23 Jun 2011 17:09:09 GMT
Server:ASP.NET Development Server/9.0.0.0
X-AspNet-Version:2.0.50727
X-AspNetMvc-Version:2.0

When running through live site

Cache-Control:public
Content-Length:15057
Content-Type:application/pdf
Date:Thu, 23 Jun 2011 17:09:45 GMT
Server:Microsoft-IIS/6.0
X-AspNet-Version:2.0.50727
X-AspNetMvc-Version:2.0
X-Powered-By:ASP.NET

So for some reason max-age gets cleared out and I can't figure it out.

The only difference I can figure is that the dev site goes thru the Cassini web server and the live is IIS so maybe IIS is clearing out the max-age?

What do I have to do to keep the max-age value in cache-control header?

EDIT: Here's a pic of the system.webserver node in the web.config in case there might be something there to look at.

web.config

3
  • Did you check the Http Headers tab in IIS? Commented Jun 23, 2011 at 18:35
  • @Jay I just modified it to expire in two days in the HTTP headers tab, but still no change in response headers. Could it be my web.config? Maybe some HttpModule is messing with the headers? Commented Jun 23, 2011 at 18:47
  • I doubt it. Can't be 100% on this, but IIS is the last one to touch the responses as they go out. From that point an external server/network node may be playing with the headers? Commented Jun 23, 2011 at 18:51

1 Answer 1

1

Find and check the <clientCache /> line in your configuration file. Try setting cacheControlMode to UseMaxAge if that is not already the case.

For instance: <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10:00:00" />

Sign up to request clarification or add additional context in comments.

3 Comments

did that but no luck. Plus it look like only IIS 7+ supports the clientcache directive iis.net/ConfigReference/system.webServer/staticContent/…
I am sorry -- didn't notice you were using IIS6. You probably have already tried it but if not can try setting the CacheControlMaxAge in IIS as documented here: msdn.microsoft.com/en-us/library/ms524623(v=vs.90).aspx. I tried and checked it in Fiddler and it works. Other than that, I don't have any other ideas.
How exactly do I go about editing the metabase? never done that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.