How can you prevent server-side Caching in ASP.NET?

 Posted by Ddd on 2/16/2011 | Category: ASP.NET Interview questions | Views: 3860 | Points: 40
Answer:

Response.Cache.SetNoServerCaching();
This statement prevents the server-side caching.


example:

Write this directive below the Page Directive
<%@ OutputCache Duration="40" VaryByParam="None" %>


In the code behind write this code
protected void Page_Load(object sender, EventArgs e)
{
//Important
Response.Cache.SetNoServerCaching();

Response.Write(DateTime.Now.ToLongTimeString());

}

//It wil prevent Caching even when we have mentioned Caching parameters
// in the OutputCache Directive


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response