Copied to clipboard

Flag this post as spam?

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


  • DanH 36 posts 61 karma points
    Nov 16, 2010 @ 03:59
    DanH
    0

    Umbraco doesn't cache content from a "Content Picker".

    When using a content picker, the xml node content is not cached on the frontend.  Umbraco will hit the database twice every time time the page is displayed to get the xml content.

    This problem turned out to be a big deal for me because I configured my back end so that all the layout and content is separated.  This way, the client only sees items they can and should be able to edit.  While a designer can access all the layout properties.  I do this by creating a content picker for each page.

    The page template renders the content from the content picker with this line:

      <umbraco:Item runat="server" field="content" stripParagraph="true"
      xslt="umbraco.library:RenderTemplate({0})" xsltDisableEscaping="true"
      />

    The end result is that every page on my site requires a database hit that looks like this:

    exec sp_executesql N'SELECT id, createDate, trashed, parentId, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text FROM umbracoNode WHERE id = @id',N'@id int',@id=1112

    select xml from cmsContentXml where nodeID = 1112

    Any ideas on how to make Umbraco cache that content?  I really need to keep the layout and content separated.  There are too many fields I don't want a basic content editing user to be able to see or change.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 16, 2010 @ 04:37
    Tom Fulton
    0

    I think it's the umbraco.library:RenderTemplate that's doing the DB call

    One suggestion might be to replace the umbraco:Item tag with an XSLT macro and enable caching on that

  • DanH 36 posts 61 karma points
    Nov 16, 2010 @ 05:17
    DanH
    0

    Tom, It was a good idea, but it didn't work.  I put the RenderTemplate call in an xslt wrapped by a Macro with the cache settings configured.

    The next thing I tried was programatically setting the output cache settings in the master page's Page_Load event.  Like so:

            Response.Cache.SetExpires(DateTime.Now.AddMinutes(10));
            Response.Cache.SetCacheability(HttpCacheability.Server);
            Response.Cache.SetValidUntilExpires(true);
            Response.Cache.VaryByParams["*"] = true;

    This works insofar as it prevents a database hit on every page load.  It's still hitting the database instead of the in memory xml whenever the server cache expires/resets, but I can live with that.  Hopefully there are no hidden side effects to this generalized approach.

     

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Nov 16, 2010 @ 08:18
    Sebastiaan Janssen
    0

    Of course it would hit the database when the cache is expired, it needs to load the cache at some point, right? Other than that, it should not have any side effects.

    Instead of using rendertemplate, also have a look at the altTemplate approach, it might be a little easier to use, depending on your needs.

  • DanH 36 posts 61 karma points
    Nov 17, 2010 @ 05:28
    DanH
    0

    Wow, I just typed a really long reply, hit submit, the page refreshed, and my post is not there.  Poof, it's gone.

  • DanH 36 posts 61 karma points
    Nov 17, 2010 @ 05:50
    DanH
    0

    So here goes again:

    Of course it does not hit the database since rendertemplate bypasses the umbraco.config xml cache.  I just wish it did not bypass it.  The db hit doesn't concern me.  The main problem is that after a user updates/publishes content, it will not be readily available to review on the front-end until the cache expires.  So basically, it will work like all my other non-Umbraco sites.

    I don't follow how altTemplate would help me.  I may not have explained my situation well enough.

    This comes down to a basic architecural dilemma that I have been struggling with.  I have layout data and content data.  I don't want the basic editor user to have access to or even have to look at the layout data.  Originally, I used master/child document types and master/child templates to separate the data.  This worked well on the front-end.  On the back-end however, the editor user was forced to click through the master layout nodes to get to the content nodes, and would get nasty permission errors.  So my solution was to completely separate the layout and content data.  The layout document type has a content picker to choose the content document type.  Then on the frontend, the rendertemplate function takes care of rendering the content data.

    Here's a screen shot:

    This is what I see as an admin.  When the editor logs in though, they start in that Content node so they only see stuff they should.

    Probably most Umbraco sites either don't hide the layout info from the client or they do it all in the templates.  I had layout data specific to each section/page though, so I would have had to create a template for nearly every page.  Plus, I would rather manage that layout info by point and clicking rather than editing HTML.

    Sorry for the novel.  I'm really sorry I had to type it twice.  I'm curious how others have approached the same problem.  I found very little in my research.

  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2010 @ 08:10
    Rich Green
    1

    Hey Dan,

    Maybe I misunderstand your issue, however I can't see why you are not just using templates, the functionality you describe is what templates are for.

    Each docType can have one or more templates, which means the user can choose the layout they want (open up content node go to properties and select which template they want in the template dropdown) you specify in the doctype which templates are allowed. 

    In the users section you can hide all sections you don't want the user to see when they login, so they could only have access to content and media, this way they will never see the templates.

    I'm confused by this point

    "On the back-end however, the editor user was forced to click through the master layout nodes to get to the content nodes, and would get nasty permission errors. "

    Why would your editors be viewing any master templates or html? You should be able to set the site up so the editor never has to edit/see any html at all, the content and presentation can be split.

    Let me know your thoughts

    Rich

  • DanH 36 posts 61 karma points
    Nov 30, 2010 @ 17:31
    DanH
    0

    Thanks for the reply Rich.  I was in a rush to get the site published, so that is why my reply is so delayed.

    The short answer is, I want my layout items to be able to be managed through Umbraco because every page has different layout items (header image, left image, urlalias, etc). The builtin Umbraco way of managing this stuff is way easier than manually editing HTML and FTPing images.  Easy enough that I can have some grunts do the work instead of my designer or myself.  But still too hard for the client.

    The longer answer is in a new thread I created with lots of screen shots and more explanation.  If you care to read it:

    http://our.umbraco.org/forum/templating/templates-and-document-types/15135-Umbraco-backend-structure-best-practices-for-separating-layout-and-content-

    Thanks!

  • Rich Green 2246 posts 4008 karma points
    Nov 30, 2010 @ 18:33
    Rich Green
    0

    Hey Dan, 

    No worries.

    I have replied to your new thread.

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft