Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to set Cache implementation properly in asp.net with c#. I tried setting the same in both web.config and in Global.asax. Cache value coming as Private and Expires attribute value is not coming as -1.

What I have tried:

In web.config
<httpProtocol>
     <customHeaders>
       <clear/>
        <add name="Expires" value="-1" />
       <add name="Cache-Control" value="no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0" />
       <add name="Pragma" value="no-cache" />
       <!--Added by Alex on 8.11.2021 for HTTP Strict Transport Security Fix etc in addition End-->
     </customHeaders>
   </httpProtocol>

Under Global.asax
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "-1"); // Proxies.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900