Output Caching the DefaultRenderMvcController Index action method
How do you enable ASP.NET Output Caching for the DefaultRenderMvcController?
This example that I've seen in many places in this forum doesn't seem to work:
SetDefaultRenderMvcController(typeof(MyRenderMvcController)); // in a composer class
[OutputCache(CacheProfile = "MyCacheProfile")]
public override ActionResult MyRenderMvcController.Index(ContentModel model) { ... }
In a new ASP.NET MVC Web Application, this is enough to enable output caching for an action method. But for me in a new Umbraco project, it does nothing.
I've verified that my overriding Index method is actually called during rendering.
The Web.config cache settings are identical in my ASP.NET MVC project and my Umbraco project. I've tried experimenting with different profiles configurations, setting the configuration directly on the method attribute, creating a subclassed attribute, etc.
Is this supposed to work?
If so, what am I doing wrong?
If not, how do you use ASP.NET Output Caching in Umbraco?
EDIT: This works fine, unless you use the Async Output Cache Module. See below.
The problem in my case was that a previous NuGet had installed the Async Output Cache Module and replaced the out-of-the-box Output Cache Module. The Async Module does not work with Umbraco out-of-the-box, or maybe doesn't work at all anymore. After all, this is pretty ancient technology.
So, the above example I posted works fine for output caching the DefaultRenderMvcController Index action method.
In my case, the Async Output Cache Module was installed by the Redis Output Cache Provider. So, as a consequence, the Redis Output Cache Provider does not work with Umbraco, even if you replace the Async Output Cache Module with the out-of-the-box Output Cache Module.
Output Caching the DefaultRenderMvcController Index action method
How do you enable ASP.NET Output Caching for the DefaultRenderMvcController?
This example that I've seen in many places in this forum doesn't seem to work:
In a new ASP.NET MVC Web Application, this is enough to enable output caching for an action method. But for me in a new Umbraco project, it does nothing.
I've verified that my overriding Index method is actually called during rendering.
The Web.config cache settings are identical in my ASP.NET MVC project and my Umbraco project. I've tried experimenting with different profiles configurations, setting the configuration directly on the method attribute, creating a subclassed attribute, etc.
Is this supposed to work?
If so, what am I doing wrong?
If not, how do you use ASP.NET Output Caching in Umbraco?
EDIT: This works fine, unless you use the Async Output Cache Module. See below.
The problem in my case was that a previous NuGet had installed the Async Output Cache Module and replaced the out-of-the-box Output Cache Module. The Async Module does not work with Umbraco out-of-the-box, or maybe doesn't work at all anymore. After all, this is pretty ancient technology.
So, the above example I posted works fine for output caching the DefaultRenderMvcController Index action method.
https://devblogs.microsoft.com/aspnet/introducing-the-asp-net-async-outputcache-module/
In my case, the Async Output Cache Module was installed by the Redis Output Cache Provider. So, as a consequence, the Redis Output Cache Provider does not work with Umbraco, even if you replace the Async Output Cache Module with the out-of-the-box Output Cache Module.
I've made an open source package for this: https://marketplace.umbraco.com/package/umbracooutputcache
is working on a reply...