
Adding public private cache header code#
(i.e: setting no-cache, when it is private)īut, if you want to set to a less restrictive value than it already is (i.e: setting to private, when it is no-cache), the code below will not work: (HttpCacheability. If you are setting the cache control to a more restrictive value than it already is, it is fine.

Where are these headers getting overridden and how can I stop it?ĮDIT: I have checked and the incorrect headers are being sent to Chrome, FF, IE and Safari, so it looks to be a server problem not a browser related problem. Which is closer, but still not the headers that I want to send. The max-age value is set in seconds, for example, max-age300 for a five-minute TTL, and max-age63072000 for two years. directive, like so: Header set Cache-Control 'max-age84600, public'. Then the client response headers change to: Cache-control: no-cache In Apache, you'll have to set this header manually using the. Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate") When I add ("Cache-Control") first, it makes no difference: ("Cache-Control") What happened to the cache-control header? Does something native to IIS7 or ASP.NET overwrite it? I have checked my solution and I have no code that overwrites this header. However in IIS7 / ASP.NET MVC, when I send those headers then the client sees these response headers instead: Cache-control: private, s-maxage=0 // that's not what I set them to

You get a system that can break apart a page into public and private pieces, cache each piece appropriately, and then re-compose the full-page content from the relevant caches and serve. Combine these two elements and you get something very powerful. You should add the privatedirective for user-personalized content, especially for responses received after login and for sessions managed via cookies. LiteSpeed Web Server allows you to store content in either the public cache or a private cache.

(i.e: setting no-cache, when it is private) But, if you want to set to a less restrictive value than it already is (i.e: setting to private, when it is no-cache), the code below will not work: (HttpCacheability. The privateresponse directive indicates that the response can be stored only in a private cache (e.g. Response.AppendHeader("Pragma", "no-cache") If you are setting the cache control to a more restrictive value than it already is, it is fine. This very highly rated answer (currently 1068 upvotes) says to use: Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate") I am trying to make sure that a certain page is never cached, and never shown when the user clicks the back button.
