Wednesday, 23 January 2013 13:54

how to disable cache in any page asp.net

Written by 
Rate this item
(0 votes)

you may read many article in web about how to make a page
not to be cached using meta tags like that in the head
section -

<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<meta http-equiv="cache-control" content="no-store">
</HEAD

this techniques works well with internet explorer browser and
firefox may be.but this not works will all browsers including
Chrome,opera...

but the following codes will definitely disable cache for the page
concerned in all browsers-

protected void Page_Init(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
}

Read 3700 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.