Tuesday, April 3, 2012

Clear browser cache and force page to reload on browser back button click.

To Clear the browser cache and force the page to reload on browser back button click.

protected void Page_Load(object sender, EventArgs e)
    {
         clearCache();
    }


private void clearCache()
    {
        Response.CacheControl = "no-cache";
        Response.AddHeader("Pragma", "no-cache");
        Response.AddHeader("cache-control", "no-store, no-cache, must-revalidate");
        Response.Expires = -1;
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
    }

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More