Tuesday 8 October 2013

page refresh on browser back button

Here is small code snippet which basically refreshes the page every time user comes on to this page using a back button.what it apparently do is stops the page from being cached.

I have tested it on firefox ,IE9 and 10 and Chrome.


 if (!IsPostBack)
 {
 Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
 Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
 Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
 Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
 Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1
  Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1
 Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1
 Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0
 Response.AppendHeader("Expires", ", 01 Thu 1996 05:00:00 GMT"); // HTTP 1.0
}

No comments:

Post a Comment