Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Per Bolmstedt 84 posts 380 karma points
    Dec 16, 2020 @ 16:12
    Per Bolmstedt
    0

    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.

  • Per Bolmstedt 84 posts 380 karma points
    Dec 18, 2020 @ 08:33
    Per Bolmstedt
    100

    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.

  • Prashansa 3 posts 74 karma points
    Jan 30, 2023 @ 12:47
    Prashansa
    1

    I've made an open source package for this: https://marketplace.umbraco.com/package/umbracooutputcache

Please Sign in or register to post replies

Write your reply to:

Draft