@Blog.Author(Nandip Makwana) .LearningExperience(ASP.NET, ASP.NET MVC, IIS, jQuery & Technology Surrounding it...)

December 9, 2012 comment

ASP.NET MVC: OutputCache action filter

ASP.NET MVC: OutputCache

OutputCache action filter attribute is used to control the output cache of action method result. We can also apply this attribute at controller level, once we apply this attribute at controller level, all action method result will be cached. Once action result are cached any subsequent request will be served from cache instead of processing it again.

Attribute Usage: Controller & method

Sample Code:

public ActionResult About()
    ViewBag.date = DateTime.Now.ToString();
    return View();

In above example, action method result will be cached for 60 seconds. Right usage of OutputCache attribute can help us to boost ASP.NET MVC application performance.

Apart from Duration, we can cache action result based on following criteria.

  • CacheProfile
  • Duration
  • Location
  • NoStore
  • SqlDependency
  • VaryByContentEncoding
  • VaryByCustom
  • VaryByHeader
  • VaryByParam

Check out ASP.NET MVC: Action filter series post to read about other available action filters.

You can follow me on twitter for latest link and update on ASP.NET & MVC.

comments powered by Disqus

Featured Content

Resources & Tools

About Nandip Makwana

Nandip Makwana is passionate about digital world and web. He completed his Masters in Computer Application in June 2011. Currently he is working as a Software Engineer. He has shown great promise and command over ASP.NET and technologies surrounding it during his academic years and professorial life...continue reading