Reputation: 29683
Can we have multiple OutputCache
defined for an action? For ex. say I want to store OutputCache
copy one in Server
and another one in Client
. I know that this we can do with Location=OutputCacheLocation.ServerAndClient
but say I want to specify different Duration
for Client
and Server
, having a bigger Duration
for Server
and smaller Duration
for Client
? So with this requirement can I have it as below?
[OutputCache(Duration = 3600, Location = OutputCacheLocation.Server, VaryByParam = "pID", NoStore = true)] //Server Cache for 1 hour
[OutputCache(Duration = 600, Location = OutputCacheLocation.Client, VaryByParam = "pID", NoStore = true)] //Client Cache for 10 minutes
public ActionResult GetDetails(string pID)
{
//some code
return View(model);
}
Will this be valid to have or MVC
takes latest OutputCache
into consideration?
Upvotes: 2
Views: 316
Reputation: 8781
If you look at the source of OutputCacheAttribute you will notice that the attribute is defined with AllowMultiple
property set to false:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class OutputCacheAttribute : ActionFilterAttribute, IExceptionFilter
So it won't work
Upvotes: 4