什么是设置no-cache ="Set-Cookie"

sba*_*y71 9 cache-control httpcontext

我正试图让我的头球更好.我在vb.net中有以下代码:

With HttpContext.Current.Response 
   .Cache.SetCacheability(HttpCacheability.Public)
   .Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
   .Cache.SetLastModified(Now)
   .Cache.SetExpires(DateTime.UtcNow.AddSeconds(120))
   .Cache.SetMaxAge(TimeSpan.FromSeconds(120))
End With
Run Code Online (Sandbox Code Playgroud)

返回以下标题:

Cache-Control: public, no-cache="Set-Cookie", must-revalidate, max-age=120
Content-Type: application/xml; charset=utf-8
Expires: Mon, 22 Aug 2016 13:54:36 GMT
Last-Modified: Mon, 22 Aug 2016 13:52:36 GMT
Run Code Online (Sandbox Code Playgroud)

但我想弄清楚什么是设置no-cache="Set-Cookie",如何打开或关闭?

小智 5

no-cache="Set-Cookie" 告诉浏览器不要缓存服务器“Set-Cookie”标头,但对请求的其余部分遵循不同的规则。这是 W3C 的讨论 http://www.w3.org/Protocols/HTTP/Issues/cache-private.html

在 http 1.1 中,Roy 为新的缓存控制指令提出了一些功能,允许服务器有选择地禁用特定标头的缓存。例如:cache-control: no-cache="set-cookie"

  • 我理解您链接的文档的方式是,如果存在“Set-Cookie”标头,则不会缓存整个响应。最好能澄清这一点以及浏览器支持。 (5认同)