views:

56

answers:

1

Hi folks,

I'm trying to set the cachability of an ASP.NET resource. So if I goto /foo/show it will show a View for some resource, and cache this for a few hours (for example). To do this, I'm using the OutputCache attribute which decorates my Action Method. The details of this cache (against this action method) are found in the web.config file.

When I set this Output Cache, it's correctly setting the maxage value .. but the s-maxage value is 0. WTF?

here's the code...

[Authorize]
[OutputCache(CacheProfile = "SomeController_Show")]
public ActionResult Show(){ ... }

and here's a snippet of the config file..

<add name="SomeController_Show" duration="3600" varyByParam="authkey;format;blah"  />

and a snippet of the response...

Cache-Control:public, max-age=3576, **s-maxage=0**
Content-Length:746
Content-Type:application/json; charset=utf-8
Date:Tue, 10 Aug 2010 00:42:17 GMT
Expires:Tue, 10 Aug 2010 01:41:53 GMT
Last-Modified:Tue, 10 Aug 2010 00:41:53 GMT
Server:Microsoft-IIS/7.0
Vary:*

Notice how the maxage is correctly set but the s-maxage is NOT? can someone help me out, here?

A: 

I found the answer, the [AuthorizeAttribute] clears any maxage to zero. This means, no proxies every cache a view result that has Authorization.

I'm guessing proxies cache content via the url .. so if the url doesn't contain any authentication details (which is really shouldn't... :) ) .. then how does it know which two differing requests are for the same person or not?

(I've added this answer instead of deleting, to help other dev's with this issue).

Also, SIMILAR QUESTION: http://stackoverflow.com/questions/2983030/can-someone-explain-this-block-of-asp-net-mvc-code-to-me-please

Pure.Krome