Copied to clipboard

Flag this post as spam?

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


  • Mustufa Baig 19 posts 41 karma points
    Jul 06, 2011 @ 20:59
    Mustufa Baig
    0

    Razor - Output Caching

    Hi there

    In webforms view engine any c# code which is used on the ASCX file will be run on every hit. Thats why we should keep any processing or data access inside code behind so that it can be cached.

    How does it work in razor files? They do not seem to have code behind files.

    Thanks

     

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jul 07, 2011 @ 14:03
    Dan Diplo
    0

    You can cache inline Razor macros by adding a Cache="300" (where 300 is the time in seconds you want to cache content for). eg.

    <umbraco:Macro ID="MacroCached" runat="server" language="razor" Cache="300">
    Cached at @DateTime.Now
    </umbraco:Macro>

    This doesn't seem to work for non-inline Macros. See http://our.umbraco.org/forum/developers/razor/17838-inline-razor-macro-caching 

Please Sign in or register to post replies

Write your reply to:

Draft