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?
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?
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.
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:
The site is running Umbraco v4.9.0
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
Have you tried setting the property CacheByPage="true" on the macro ?
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
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.
Worked perfectly thanks Matt!
Whoop whoop! :)
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>
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
is working on a reply...