3

What is difference between

  • HttpCacheability.NoCache
  • HttpCacheability.Server
  • HttpCacheability.Public
  • HttpCacheability.Private
  • HttpCacheability.ServerAndNoCache

At which condition we should use which one?

1
  • MSDN page about HttpCacheability explains this topic very well.They also provide a link to complete W3C specification (if you need more details). Commented Jul 30, 2015 at 9:23

2 Answers 2

2

From MSDN

  • NoCache :

    Sets the Cache-Control: no-cache header. Without a field name, the directive applies to the entire request and a shared (proxy server) cache must force a successful revalidation with the origin Web server before satisfying the request. With a field name, the directive applies only to the named field; the rest of the response may be supplied from a shared cache.

  • Private

    Default value. Sets Cache-Control: private to specify that the response is cacheable only on the client and not by shared (proxy server) caches.

  • Public

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

  • Server

    Specifies that the response is cached only at the origin server. Similar to the NoCache option. Clients receive a Cache-Control: no-cache directive but the document is cached on the origin server. Equivalent to ServerAndNoCache.

  • ServerAndNoCache

    Applies the settings of both Server and NoCache to indicate that the content is cached at the server but all others are explicitly denied the ability to cache the response.

  • ServerAndPrivate

    Indicates that the response is cached at the server and at the client but nowhere else. Proxy servers are not allowed to cache the response.

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

3 Comments

Thanks Jamie, i read it already but i want to know in simple words!
Is there no option to cache both publicly on clients, and on the server? Or will Public also cache on the server?
@RuudLenders sounds like you want ServerAndPrivate
2
NoCache: nobody can cache the page. Private: only browsers can cache it (but not shared proxies). This is the default value Public: everybody can cache the page, proxies included Server: pages are cached only on the server (like the NoCache, so browsers don't cache the page) ServerAndNoCache: pages are cached only on the server (like the NoCache, so browsers don't cache the page) ServerAndPrivate: only browsers can cache it (but not shared proxies). 

You can read more here:

http://codeclimber.net.nz/archive/2007/04/01/Beware-the-ASP.NET-SetCacheability-method.aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.