HttpCacheability.NoCache和HttpCacheability.ServerAndNoCache之间的区别是什么?

3

什么是

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

它们之间有何不同?在哪种情况下应使用哪个?


MSDN关于HttpCacheability的页面解释了这个主题非常清楚。他们还提供了一个完整的W3C规范链接(如果您需要更多细节)。 - Adriano Repetti
2个回答

2

来自MSDN

  • NoCache :

    设置Cache-Control:no-cache头。如果没有字段名,指令应用于整个请求,共享(代理服务器)缓存必须在满足请求之前强制使用原始Web服务器进行成功的重新验证。有了字段名,指令仅适用于命名字段;响应的其余部分可以从共享缓存中提供。

  • Private

    默认值。 设置Cache-Control:private以指定响应仅可由客户端缓存,而不是共享(代理服务器)缓存缓存。

  • Public

    设置Cache-Control:public以指定响应可由客户端和共享(代理)缓存缓存。

  • Server

    指定响应仅在源服务器上缓存。类似于NoCache选项。客户端接收到Cache-Control:no-cache指令,但文档被缓存在源服务器上。相当于 ServerAndNoCache。

  • ServerAndNoCache

    将Server和NoCache的设置应用于指示内容在服务器上被缓存,但所有其他人都明确禁止缓存响应。

  • ServerAndPrivate

    指示响应在服务器和客户端上都被缓存,但其他地方不允许代理服务器缓存响应。


谢谢Jamie,我已经阅读了它,但我想用简单的话来表达! - Narender Dhull
有没有在客户端和服务器上都进行公共缓存的选项?或者“Public”也会在服务器上缓存吗? - Rudey
@RuudLenders 听起来你想要 ServerAndPrivate - Jamie Rees

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). 

您可以在这里阅读更多:

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接