You can use output caching in asp.net-mvc based on your controller action parameters

I want to use output caching to not hit my db again and again with the same static request, but my controllers have parameters that uniquely determine the message.

How can I affect my settings and still support output caching in asp.net-mvc?

+3
source share
1 answer

Check the VaryByParam property of the OutputCache attribute.

[OutputCache(Duration=int.MaxValue, VaryByParam="id")]
public ActionResult Details(int id)
{
}

For each unique id value, a unique cache instance will be created.

Edit:

VaryByParam, VaryByCustom. ( , ..).

+7

All Articles