We recently came across a scenario where an ASP.NET page was caching on the user's browser and causing issues. ASP.NET pages are dynamic and their content should never cache. To force the browser to not cache the page, add the following code:
Code-behind
1Response.AppendHeader("Cache-Control", "no-cache; private; no-store;
must-revalidate; max-stale=0; post-check=0; pre-check=0; max-age=0");
2Response.AppendHeader("Pragma", "no-cache");
3Response.AppendHeader("Keep-Alive", "timeout=3, max=993");
4Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
//Some random old date
HTML META tags
1<meta http-equiv=expires content=-1>
2<meta http-equiv=Cache-Control CONTENT=no-cache>
3<meta http-equiv=Pragma CONTENT=no-cache>
Comments
Leave a Comment