0
votes

I'm trying to setup global server side output caching for our public site. I can see there is an OutputCache attribute that lets you control this. This works fine if i register it globally in the filterConfig like this

filters.Add(new OutputCacheAttribute() { Duration = 3600, VaryByParam = "*" });

The problem is that this enables caching on the client side and this causing issue with some redirect logic we have setup. So we need to

But if set the location property to Server like this

filters.Add(new OutputCacheAttribute() { Duration = 3600, VaryByParam = "*", Location = OutputCacheLocation.Server });

then this causes the following exception on some pages with child actions.

OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding, or VaryByHeader values for child actions

Is there a way to enable server side caching globally? Can anyone explain why this does not work?

1

1 Answers

0
votes

That is a limitation in MVC. However you can use custom output caching. follow this link

you can install MvcDonutCaching using NuGet

and replace OutputCache... with DonutOutputCache...