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

    Ebook Download
    View all
    Learn
    View all
    59 2.8k8.7k

    An author is the creator or originator of any written work such as a book or play, and is also considered a writer or poet. More broadly def... Know more