Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Nov 02, 2012 @ 15:43
    Simon Dingley
    0

    Caching Macros by Page that use FileLocation Property

    Is it possible to cache macros by page that use the FileLocation property? I've got a multi-site/multi-language site that get's all mixed up due to the caching being implemented globally. FileLocation is great as it means not having to explicityly define Macros in the database however it's not so great if it does not inherit the same feature set?

    Anyone come up against this and found a solution?

    Example macro tag:

    <umbraco:Macro runat="server" Language="cshtml" Alias="TwitterFollowPanel" FileLocation="~/macroScripts/TwitterFollowPanel.cshtml" Cache="300" />

    The site is running Umbraco v4.9.0

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 02, 2012 @ 15:48
    Matt Brailsford
    1

    Couldn't you define an attribute on the macro that changes per site / language that will get made part of the cache key?

    http://blog.mattbrailsford.com/2011/02/01/caching-an-umbraco-macro-by-querystring-parameter/

    Matt

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Nov 02, 2012 @ 15:49
    Dave Woestenborghs
    0

    Have you tried setting the property CacheByPage="true" on the macro ?

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Nov 02, 2012 @ 15:57
    Simon Dingley
    0

    Thanks Matt, I wasn't aware of that and will certainly give it a go.

    Dawoe, I took a quick look at the source and didn't notice that property being supported on the Macro control itself - have you found that it actually does work?

    Simon

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Nov 02, 2012 @ 16:09
    Dave Woestenborghs
    0

    Hi Simon,

    I haven't tested it yet but you can give it a try.

    Going with matt's solution you could a parameter containing the node id. Than it will be cached by that.

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Nov 02, 2012 @ 16:13
    Simon Dingley
    0

    Worked perfectly thanks Matt!

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 02, 2012 @ 16:17
    Matt Brailsford
    0

    Whoop whoop! :)

  • David Dimmer 76 posts 134 karma points
    Nov 05, 2012 @ 01:55
    David Dimmer
    0

    Is there a way to Cache by page - or better yet by node?  This doesn't throw an error, but it only caches the first node that loads.  

     

    <umbraco:Macro runat="server" language="cshtml" Cache="120" CacheByPage="true">

    </umbraco:Macro>

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Nov 05, 2012 @ 10:35
    Simon Dingley
    0

    David, CacheByPage doesn't appear to be a valid property on the Macro control, only the Cache property works. If you read the post from Matt which I have marked as the solution it solves the issue I had and should also help you to resolve your current issue.

    HTH, Simon

Please Sign in or register to post replies

Write your reply to:

Draft