I honestly don't think there's that much (if any) difference, performance wise, if you use XSLT or Razor :-) As for macros: they're basically just "containers" which holds a reference to your XSLT, .NET controls or Razor files.
XSLT & Razor macros are comparable in performance, as they both use the underlying umbraco.config XML cache to populate their data in memory, except when you are using .NET XSLT extensions - then Razor macros are faster, as they are compiled & have easier in-memory access to .NET classes & methods than XSLT does.
Here's a quick (but not exhaustive) performance guide:
Inline page macros (using the <umbraco:Macro language="xslt/cshtml"> markup) are slower than configuring a specific macro in memory, as the inline macro is compiled at runtime and creates un-necessary temp files on disk in your App_Data folder. A pre-configured macro can be cached in memory;
XSLT is normally faster than Razor unless you need helper methods - in which case, use Razor, as XSLT takes longer to load & call .NET helper methods;
Usercontrols are never cached, even if you select caching options in the macro's config, unless you write your own cache mechanism in the code-behind of the usercontrol - therefore for read-only presentation data, avoid them wherever possible;
If using usercontrols or Razor, and you only need read-only data (without previous version information), use the Node classes in the umbraco.NodeFactory namespace, or the DynamicNode classes in the umbraco.MacroEngines namespace, rather than the Document class in umbraco.cms.businesslogic.web. The Document class populates data from the database which has a performance hit, but subsequently can be used to access previous document version data, along with editing document content & properties (Node & DynamicNode only provides a read-only class view of a document).
I hope this is a good guide to better performance within your Umbraco site.
Jeroen - great spot, thanks for the heads-up. Might look into this - I personally thought DynamicNode was a full replacement for XSLT on the umbraco.config.
The more I use Razor and DynamicNode the more I get a feeling that it's not mature yet. In 4.7 Razor added some great features, but the fact that it has an XPath method already says that you can't do everything with it yet. I Already explained here that I would like to use some LINQ queries in Razor to query my data: https://groups.google.com/d/msg/umbraco-dev/PaCfxpLZsY4/eiBc-JIvjgMJ.
"Usercontrols are never cached, even if you select caching options in the macro's config, unless you write your own cache mechanism in the code-behind of the usercontrol - therefore for read-only presentation data, avoid them wherever possible;"
Wow. Really? Why is this the case?? That's a major dissapointment - part of what i liked about Umbraco is the flexibility to build in xslt,razor, or traditional .net usercontrols.
Why is it that usercontrols are not cached even when setting them to be cached? Is this something that can be considered a bug and fixed?
Performance Increase
Hi ,
Using Xslt,Razor or Macro which help the performance increases and load page fastly..
Hi mithun,
I honestly don't think there's that much (if any) difference, performance wise, if you use XSLT or Razor :-) As for macros: they're basically just "containers" which holds a reference to your XSLT, .NET controls or Razor files.
So, I'd say: go for whatever you like :-)
All the best,
Bo
Hi Bo Mortensen,
Thankz for reply...
regards
Mithun
Hi Mithun,
XSLT & Razor macros are comparable in performance, as they both use the underlying umbraco.config XML cache to populate their data in memory, except when you are using .NET XSLT extensions - then Razor macros are faster, as they are compiled & have easier in-memory access to .NET classes & methods than XSLT does.
Here's a quick (but not exhaustive) performance guide:
If you're using Razor it could have some performance problems if you don't know how to do some things properly. More info here: https://groups.google.com/forum/#!topic/umbraco-dev/ZzP2L0c_znA%5B1-25%5D.
Jeroen
Jeroen - great spot, thanks for the heads-up. Might look into this - I personally thought DynamicNode was a full replacement for XSLT on the umbraco.config.
Best,
Benjamin
The more I use Razor and DynamicNode the more I get a feeling that it's not mature yet. In 4.7 Razor added some great features, but the fact that it has an XPath method already says that you can't do everything with it yet. I Already explained here that I would like to use some LINQ queries in Razor to query my data: https://groups.google.com/d/msg/umbraco-dev/PaCfxpLZsY4/eiBc-JIvjgMJ.
Jeroen
"Usercontrols are never cached, even if you select caching options in the macro's config, unless you write your own cache mechanism in the code-behind of the usercontrol - therefore for read-only presentation data, avoid them wherever possible;"
Wow. Really? Why is this the case?? That's a major dissapointment - part of what i liked about Umbraco is the flexibility to build in xslt,razor, or traditional .net usercontrols.
Why is it that usercontrols are not cached even when setting them to be cached? Is this something that can be considered a bug and fixed?
Thanks
is working on a reply...