Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
this is possibly a stupid question, but I was wondering ... if you add a Macro to a Document Property of a page, does that Macro get called every time the page gets served, or only when the page is saved on the back-end?
In case you're wondering ... I'm trying to create a dynamic Meta tag, which depends on Archetype data (also a document property). So, when I change the Archetype data, I want the meta tag Description to reflect these changes.
The Macro executes everytime the page it is on is requested (rather than at the point of insertion in the backoffice) this is good, as the macro remains up-to-date when content changes throughout the system.
The downside of this could be if the macro is complicated, executing it on every request could slow the site down.
Therefore it is also possible to 'cache' macro output - if you look at the macro in the developer - macros section in the backoffice you can provide a number of seconds for which to cache the output of the macro for. Whenever a page is published in Umbraco the cache is broken. So you could cache the output of your Dynamic Meta Tag Macro Output, for 86400 seconds and the macro would run only once a day for the first person to visit - but if the underlying archetype data changes, the cache will be broken, and the next person who visits the site, will trigger the caching of the updated macro.
If the macro output is specific to the page you are on (eg a breadcrumb macro) then you would need to tick the 'cache by page' box to prevent the same breadcrumb from being displayed on every page!!
Hi Marc, thanks for your very helpful response. One more question if I may, can I make the same apply to partial view macro's?
A Partial View Macro, is a way to implement a Macro and so can take advantage of the caching / parameter settings in the back office.
If you need to call a Partial View (that is not a Macro Partial) directly from your view then you can apply caching using:
@Html.CachedPartial("MyPartialName", new MyModel(), 3600)
OK thx Marc
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted