Copied to clipboard

Flag this post as spam?

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


  • Michael Lund 3 posts 33 karma points
    Sep 01, 2009 @ 12:00
    Michael Lund
    0

    Cache problems

    I have a problem, which i believe i narrowed down to some inconsistency with cache.

    The problem is that sometimes, umbraco seem to return empty data for the content of a node, even though the node exists and it can write out the name.

     

    Umbraco version : umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)

    asp.net version: Microsoft .NET Framework version:2.0.50727.1433; ASP.NET version:2.0.50727.1433

    Windows Version: client is windows xp sp3, server is Windows 2003 Server standard with sp2

    I use the follwing code to write out the title field of a node, and if no title, it writes out name instead, problems is that randomly, the title is empty.

    -- Code Start --

        <li>
         <a href="#" title="{$currentPage/data [@alias = 'title']}" class="dropper" id="drop_item2" onclick="return false;">
          <span class="label">
           <xsl:choose>
            <xsl:when test="string($currentPage/data [@alias='title']) != ''">
             <xsl:value-of select="$currentPage/data [@alias='title']"/>
            </xsl:when>
            <xsl:otherwise>
             <xsl:value-of select="$currentPage/@nodeName"/>
            </xsl:otherwise>
           </xsl:choose>
          </span>
          <xsl:if test="string($itm/@nodeTypeAlias)!='Homepage'">
           <span class="click">
            <input type="button" value="" onclick="toolbar.show(this,'drop_item2');" onblur="toolbar.hide(this,'drop_item2');" class="click_convert" />
           </span>
          </xsl:if>
         </a>
        </li>
    -- Code End -- 

    I put the following code i app_code to delete the cache xml and restart the application on publish, but that doesn't solve the issue every time.

    -- Code Start --

    using System;
    using System.IO;
    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    using System.Web;

    namespace BystedUmbraco
    {
     public class FireBeforePublish : ApplicationBase
     {
      public FireBeforePublish()
      {
       Document.BeforePublish += DocumentBeforePublish;
      }

      static void DocumentBeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
      {
       string filePath = HttpContext.Current.Server.MapPath("/data/umbraco.config");
       Log.Add(LogTypes.Custom, sender.Id, filePath);
       if (File.Exists(filePath))
       {
        try
        {
         Log.Add(LogTypes.Custom, sender.Id, "umbraco.config deleted");
         File.Delete(filePath);
        }
        catch (Exception)
        {

         Log.Add(LogTypes.Custom, sender.Id, "Could not delete");
        }

       }
      }
     }

     public class PublishClearCache : ApplicationBase
     {
      public PublishClearCache()
      {
       Document.AfterPublish += DocumentAfterPublish;
      }

      static void DocumentAfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
      {
       Log.Add(LogTypes.Custom, sender.Id, "Restart");
       HttpRuntime.UnloadAppDomain();
      }
     }
    }
    -- Code End --

    Also tried doing a full publish after editing an item, and again, only solves it sometimes, not all the time.

    I hope someone can help me.

  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Sep 01, 2009 @ 13:35
    Douglas Robar
    0

    The XSLT looks fine. No need for the app_code so I'd remove that to remove another variable while debugging this.

    What settings do you have for caching in the Macro associated with your xslt file? Try setting the cache period to zero (0) and save the macro. Do you always get the right output? If so, then you may have not set the various caching options properly for your use. You would, for instance, want to select the 'by page' option since the output of the macro will be different for every page.

    Let us know what you find out.

    cheers,
    doug.

  • Michael Lund 3 posts 33 karma points
    Sep 01, 2009 @ 14:00
    Michael Lund
    0

    Hi Doug

    I removed the app_code, problem still there.

    Macros were set to 0, but not by page, checkin that just seemed to make the problem worse, before it was only once in a while it didn't get title, and with by page, it seems to do it every other refresh of the page.

    The error is the same in the masterpage for the content, where it outputs the "useIfEmpty" value instead of title, its consistant that both the xslt and the masterpage either displayes correctly or incorrectly at the same time.

    -- Begin page --

    <%@ Master Language="C#" MasterPageFile="/masterpages/Base.master" AutoEventWireup="true" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
     <umbraco:macro alias="GetBreadcrumbSession" runat="server"></umbraco:macro>
     <div class="content">
      <div class="left">
       <div class="inn">
        <div class="head">
         <p class="hd">
          <umbraco:Item field="title" useIfEmpty="pageName" runat="server"></umbraco:Item></p>
        </div>
        <div class="article">
         <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
        </div>
        <umbraco:Macro Alias="SeeAlso" runat="server"></umbraco:Macro>
       </div>
      </div>
      <div class="right">
       <div class="inn">
    <umbraco:Macro Alias="Pagemediarightcolumn" runat="server"></umbraco:Macro>
    <umbraco:Macro Alias="Faktaboks" runat="server"></umbraco:Macro>
    <umbraco:Macro Alias="ItemSubmenu" runat="server"></umbraco:Macro>
       </div>
      </div>
      <div class="clear"><!-- &#160; --></div>
     </div>
    </asp:Content>

    -- End page --

  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Sep 01, 2009 @ 15:16
    Douglas Robar
    100

    Now that IS weird! I do this kind of thing all the time and have never had a problem nor heard of anyone having this problem. For what it's worth, setting the 'by page' shouldn't do anything if the cache period is zero.

    I've only got one (totally strange and rather unlikely) idea... check your website's application pool and be sure you don't have it set up to run as a 'web garden'. You must use a single worker process. Otherwise, you're creating a "web garden" and that isn't supported by umbraco. You can create a "web farm" with load balancers and multiple servers but not web gardens.

    And the "when all else fails" answer... check that you have proper permissions on the /data folder and especially the /data/umbraco.config file. Go ahead and delete the /data/umbraco.config file. It should be re-created automatically by umbraco. If it isn't, you've got a file permission problem. When it's resolved umbraco will recreate the umbraco.config file and your site will be running normally.

    Hopefully someone else will chime in with some ideas.

    cheers,
    doug.

  • Michael Lund 3 posts 33 karma points
    Sep 01, 2009 @ 17:13
    Michael Lund
    0

    It seems it was the web garden setting, the hosting provider had it set to 2, changed it to 1 and looks like the problem has been solved, thank you very much.

    /Michael

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies