To improve performance we use caching.
OutPut Caching
To enable output caching by adding an [OutputCache] attribute to either an individual controller action or an entire controller class
OutPut Caching
To enable output caching by adding an [OutputCache] attribute to either an individual controller action or an entire controller class
[OutputCache(Duration=50, VaryByParam="none", Location=OutputCacheLocation.Client)]
The Location property to any one of the following values: · Any · Client · Downstream · Server · None · ServerAndClient
Application/Data Caching
It is meant to store Data-objects on cache.
public ActionResult Index3()
{
if (System.Web.HttpContext.Current.Cache["time"] == null)
{
System.Web.HttpContext.Current.Cache["time"] = DateTime.Now;
}
ViewBag.Time = ((DateTime)System.Web.HttpContext.Current.Cache["time"]).ToString();
return View();
}
No comments:
Post a Comment