How To Do Caching In Asp.Net MVC
Today, I want to talk about how to do caching in Asp.Net MVC projects. Microsoft Asp.Net MVC framework has builtin support for caching mechanism. We will use this with annotations OutputCache to our controllers.
[OutputCache(Duration = 60, Location = OutputCacheLocation.Client, NoStore = true)]
public ActionResult AddTask()
In this code, Duration means response cache time in seconds. If you use the Location property of output cache, you can control the output cache location. For instance, if you want some personal information is cached, then I recommend you to cache it on the client. If your output data is private/confidential, you shall not to store it in the cache.
If you want to inform proxy servers use the NoStore property. And they should not store a permanent copy of the cached content by setting Cache-Control: no-store within the request header.
Output caching allows you to store the output of a particular controller action in memory. Then the ASP.net engine can respond to future requests for the same action just by giving back the cached result. You should have a look at my another post about Logging In Asp.Net MVC
If you have question do not forget to write from the chat button next to it or from the comment