How to set CacheControl S-MaxAge value in ASP.NET application?

I am trying to set the cachability of an ASP.NET resource. Therefore, if I goto / foo / show, it will show View for some resource and close it for several hours (for example). To do this, I use the OutputCache attribute, which decorates my action method. Details of this cache (against this action method) are in the web.config file.

When I set this output cache, it sets the maxage value .. correctly, but the s-maxage value is 0. WTF?

here is the code ...

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

and here is a fragment of the configuration file.

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

and a fragment of the answer ...

 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 maxage is installed correctly, but s-maxage is NOT? can someone help me here?

+7
caching asp.net-mvc outputcache
source share
1 answer

I found the answer, [AuthorizeAttribute] clears any value to zero. This means that no proxy servers cache the viewing result that has authorization.

I guess the contents of the proxy cache via url .. so if the URL does not contain authentication information (which really shouldn't ... :)), then how does it know which two different requests are for the same person or not?

(I added this answer instead of deleting to help other developers with this problem).

ALSO LIKE QUESTION: Can someone explain this ASP.NET MVC code code to me, please?

+12
source share

All Articles