We can create a cache profile in the web.config file and it is an alternative to configuring output cache properties by
modifying properties of the [OutputCache] attribute. It also offers a couple of important advantages which are as follows.
It Controls how controller actions cache content in one central location.
It creates one cache profile and applies the profile to several controllers or controller actions.
It modifies the web configuration file without recompiling your application.
It disables caching for the application that has already been deployed to production.
First, take a look at a simple example of a cache profile by creating the cache profile on web.config file. These <caching> section must appear within the <system.web> section.
We can apply the Cache10Min profile to a controller action with the [OutputCache] attribute which is as follows.
[OutputCache(CacheProfile = "Cache10Min")]
public ActionResult Index(){ var employees = from e in db.Employees
orderby e.ID
select e;
return View(employees);
}
Run the application and specify the following URL http://localhost:63004/employee
If we invoke the Index() action as shown above then the same time will be returned for 10 Min.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
We can create a cache profile in the web.config file and it is an alternative to configuring output cache properties by modifying properties of the [OutputCache] attribute. It also offers a couple of important advantages which are as follows.
First, take a look at a simple example of a cache profile by creating the cache profile on web.config file. These <caching> section must appear within the <system.web> section.
We can apply the Cache10Min profile to a controller action with the [OutputCache] attribute which is as follows.
Run the application and specify the following URL http://localhost:63004/employee
If we invoke the Index() action as shown above then the same time will be returned for 10 Min.