Caching In ASP.NET MVC again

Caching

Caching is used to improve the performance in ASP.NET MVC. Caching is a technique which stores something in memory that is being used frequently to provide better performance. In ASP.NET MVC, OutputCache attribute is used for applying Caching. OutputCheching will store the output of a Controller in memory and if any other request comes for the same, it will return it from cache result.

OutputCache attribute can have a parameter.

Duration

It describes the time in seconds.

    The example of duration is given below.

    1. [OutputCache(Duration = 60)]
    2. public ActionResult Index() {
    3. var emps = from e in db.Employees
    4. orderby e.ID
    5. select e;
    6. return View(emps);
    7. }
    VaryByPara

    Up Next
      Ebook Download
      View all

      testing

      Read by 48 people
      Download Now!
      Learn
      View all