views:

88

answers:

4

If you set caching (as below) in an HTTP handler, will it be cached on the server or client or both?

_context.Response.Cache.SetCacheability(HttpCacheability.Public);
_context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(180));
A: 

The code you used above will cache the content on the clients browser.

If the expiry date of the content is within the time specified then the browser (client side) will issue a 304 "Not Modified" i.e. The Content is cached and not re fetched from the server.

Hope this helps

G

gg
+1  A: 

This sets the http header, which means it will be cached by:

  • The client
  • A server "on the way" to the client, such as an ISA server
Sohnee
A: 

Cache-Control: public to specify that the response is cacheable by clients and shared (proxy) caches.

http://msdn.microsoft.com/en-us/library/system.web.httpcacheability%28VS.71%29.aspx

Regards --Jocke

Jocke
+1  A: 

For the following call:

_context.Response.Cache.SetCacheability(HttpCacheability.Public);

it turns out that in addition to setting the Cache-Control: public HTTP header, it also enables server-side output caching.

RickNZ