12

I'm trying to get my header rounder Caching. I have the following code in 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

Which returns the following headers:

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

But I'm trying to figure out what is setting no-cache="Set-Cookie" and how can I switch that on or off?

Castaglia
  • 2,972
  • 5
  • 28
  • 49
sbarnby71
  • 584
  • 4
  • 7
  • 21

1 Answers1

5

The no-cache="Set-Cookie" tells the browser not to cache the server "Set-Cookie" header, but follow different rules for the rest of the request. Here's a discussion from W3C http://www.w3.org/Protocols/HTTP/Issues/cache-private.html

In http 1.1, Roy has proposed some features for the new cache-control directive that allow servers to selectively disable caching on specific headers. This would be, for example: cache-control: no-cache="set-cookie"

Mike F.
  • 51
  • 1
  • 3
  • 5
    The way I understood that document you linked is that if the "Set-Cookie" header is present then the entire response is not cached. Would be good to get clarification on that and also browser support. – Elijah Lynn Feb 22 '18 at 03:41