Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC: OutputCache and http headers - Cache-Control

I have just started using OutputCache on some of my controller actions and I am not quite getting the response I would expect.

Basically I have set Location = OutputCacheLocation.Any and the http header is as follows:

Server              ASP.NET Development Server/9.0.0.0
Date                Wed, 15 Jul 2009 02:14:21 GMT
X-AspNet-Version    2.0.50727
X-AspNetMvc-Version 1.0
Content-Encoding    gzip
Cache-Control       private, max-age=3600
Expires             Wed, 15 Jul 2009 02:14:21 GMT
Last-Modified       Wed, 15 Jul 2009 02:14:20 GMT
Vary                *
Content-Type        text/html; charset=utf-8
Content-Length      640
Connection          Close

Now if my interpretation is correct the Cache-Control part being set to private means that it will only be cached on the client. I need to also be cached on any proxy.

I would have expected that by setting OutputCacheLocation.Any the Cache-Control would have been something like "public, max-age=3600". As far as I know the private means it will only be cached on the client and not by "Any" (i.e. proxies - see http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx).

Any ideas?

Cheers Anthony

like image 812
vdh_ant Avatar asked Nov 27 '25 17:11

vdh_ant


1 Answers

See comments above for solution

EDIT

This comment was deemed the answer:

Have you tried publishing your site to IIS and looking at the headers there? Is it the same as on the dev server? –

like image 181
vdh_ant Avatar answered Nov 29 '25 10:11

vdh_ant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!