Reputation: 1252
I encountered with it while I was reading this article from MSDN documentation. I am pretty newbie about caching, in fact, one of the first articles that I read about caching. Can you explain me simply?
Upvotes: 2
Views: 3686
Reputation: 2256
In short its a caching profile that you can set in the web.config
instead of having to apply the settings to every Action or Controller you want to use the cache settings with:
In web.config you specify options for the cache profile:
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="cp1" duration="30" location="Any" varyByHeader="user-agent" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
Then anywhere you want to use the profile you can just use e.g.
[OutputCache(CacheProfile="cp1")]
public ActionResult Index() {
//...
}
Above example taken from Apress Pro ASP.NET MVC 5 Platform by Adam Freeman. I recommend it as a good read.
Upvotes: 9