Copied to clipboard

Flag this post as spam?

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


  • Kasper Dyrvig 246 posts 379 karma points
    Jan 29, 2020 @ 13:55
    Kasper Dyrvig
    0

    Macro caching per page and language

    Hi

    I noticed that my macros set to cache by page do not change content if I switch language. Yet, it seems only to be the case with macros inserted via RTE.

    And I do not see any documentation for that situation on https://our.umbraco.com/documentation/Reference/Templating/Macros/#caching-macro-output

    Anyone who has some experience to share on this?

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Feb 03, 2020 @ 19:12
    Marc Goodson
    1

    Hi Kasper

    Yes, I have run into this, it is I think an oversight with variants in Umbraco V8 - essentially the 'cache key' when 'caching is set for a macro' by page, uses the Id of the page along with the values of any macro parameters. In V7 this would ensure the cached version was different for each page, or if the macro was used on the same page with different parameters.

    In V8 however, the language variant that uses the same macro 'will' have the same page id!! and so if the parameters are also the same in both versions of the macros on the different variant pages, you will get the issue you are experiencing, the output of the first requested macro cached upon the variant pages...

    I've put a PR into the core of Umbraco to report/suggest a fix for this, to use the current language name as part of the cache key:

    https://github.com/umbraco/Umbraco-CMS/pull/7555

    In the meantime, as a workaround - you could add a new parameter to your macro - called 'language' or similar... and ensure editors enter a different value here for each variant page - then the fact that the parameters have different values between the Macros will ensure that the cache is 'per' variant...

    regards

    Marc

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Mar 28, 2020 @ 10:36
    Marc Goodson
    0

    Hi Kasper

    The PR above has been accepted and has been earmarked for release as part of Umbraco v8.7 ...

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft