Copied to clipboard

Flag this post as spam?

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


  • Janusz Stabik 37 posts 59 karma points
    Feb 06, 2014 @ 22:02
    Janusz Stabik
    0

    Macro cache per instance on a page

    We have a modular mechanism whereby multiple instances of a given macro can be added to a page.  

    As such, is it possible to cache the macro per page, per instance (i.e. if we just cache the macro per page and we include the macro twice on the same page then the second instance will show the same output as the first)?

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Feb 06, 2014 @ 22:10
    Lee Kelleher
    0

    Hi Janusz,

    The cache key used by the macro is generated using the alias name, plus the additional parameters that are passed through. Not sure how you are calling the macros, but I'll use WebForms as an example...

    <umbraco:Macro runat="server" Alias="MyMacro" CustomParam1="foo" CustomParam2="bar" />
    

    I can't remember the exact format for the cache key, but this would generate something like umb_macro_MyMacro_foo_bar (you get the idea).

    So if you use the advanced macro parameter syntax you could make the cache key unique (for that instance) ...

    <umbraco:Macro runat="server" Alias="MyMacro" CustomParam1="[#pageID]" CustomParam2="[#propertyAlias]" />
    

    Then if your subsequent macros have pass in unique parameters, then they'll be cached accordingly.

    Hope this helps?

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft