Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is setting no-cache="Set-Cookie"

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?

like image 269
sbarnby71 Avatar asked Aug 22 '16 14:08

sbarnby71


People also ask

Should I use cache-control no-cache?

Cache-control: no-cache This is useful to ensure that authentication is respected among other benefits. The no-cache directive uses the ETag header field for validation of the cached response by making a roundtrip to and from the server to ensure that the response has not changed.

What is the use of no-cache?

no-cache. The no-cache response directive indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server.

What is set cookie?

The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent can send it back to the server later. To send multiple cookies, multiple Set-Cookie headers should be sent in the same response.

What is set cache-control as no-cache?

The no-cache directive means that a browser may cache a response, but must first submit a validation request to an origin server.


1 Answers

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"

like image 60
Mike F. Avatar answered Sep 29 '22 23:09

Mike F.