ASP.NET Response.Cache.SetNoStore () vs Response.Cache.SetNoServerCaching ()

Can someone break what these two methods do at the HTTP level.

We are dealing with Akamai extreme caching and said that SetNoStore () would throw an exception so that form pages (for example) would always be sent back to the original server. According to {guy}, this sets the HTTP header:

Cache-Control: "no-cache, no-store" 

When I implemented this change in our forms, I found SetNoServerCaching (). This seems semantically meaningful, and the documentation says: "Explicitly refuses to cache the document on the source server."

So, I went down to the sea to see what I see. I tried both of these methods and reviewed the headers in Firebug and Fiddler.

And from what I can say, both of these methods set the same Http header.

Can anyone explain if there are actual differences between these methods, and if so, where are the HTTP responses hiding ?!

+6
source share
2 answers

There are several differences

SetNoStore essentially stops the browser (and any network resource, such as CDN) from saving any part of the response or request, which includes saving to temporary files. This will install the NO-STORE HTTP 1.1 header

SetNoServerCaching will essentially stop the server from saving files, in ASP.NET There are several levels of caching, only data, partial queries, full pages and SQL data. This call should stop the HTTP requests (Full and Partial) that are stored on the server. This method should not set cache control headers or store or store cache.

There is also

 Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0)); 

as a possible way to set the cache, this will set the content-expires header.

For a CDN, you probably want to set the content-expires header so that it knows the CDN when to get new content if it gets a HIT. You probably don’t want the cache or not storage, as this would cause an update on every HIT, therefore, in essence, you will void any advantage that the CDN brings to you, except that they may have faster a basic connection with the end user than your current provider, but that would be insignificant.

+6
source

The difference between the two means

HttpCachePolicy.SetNoStore () or Response.Cache.SetNoStore: Prevents the browser from caching ASPX pages.

HttpCachePolicy.SetNoServerCaching or Response.Cache.SetNoServerCaching: Stops source server caching for the current response. Explicitly denies caching the document on the origin server. After installation, all requests to the document are fully processed.

When these methods are called, caching cannot be reconnected for the current response .

+5
source

Source: https://habr.com/ru/post/902340/


All Articles