Sitecore Dictionary Items

2019-07-18 16:45发布

问题:

In the earlier versions of Sitecore there were an issue with dictionary items, if we have a CDs environment, sometimes the Dictionary.dat file may not get updated on CDs server.

1) is this issue still exist with Sitecore 8 ?

2) if yes, what is the best approach to implement custom dictionary items for my website ?

回答1:

  1. I have this issue on Sitecore 8.1 Initial Release.
  2. To fix it you need to add on publish:end and publish:end:remote event a new handler. This is the class :

    public class DictionaryCacheClearer
    {
    /// <summary>
    /// Clears the whole dictionary domain cache.
    /// </summary>
    /// <param name="sender">The sender.</param>
    /// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
    public void ClearCache(object sender, EventArgs args)
    {
        Translate.ResetCache();
        Log.Info("Dictionary cleared", this);
    }
    } 
    

    On publish:end and publish:end:remote events you will have:

    <event name="publish:end:remote">
     <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
       <sites hint="list">
        <site s="1">YourSite</site>
       </sites>
      </handler>
     <handler type="YourNameSpace.DictionaryCacheClearer, YourAssembly" method="ClearCache" />
    </event>
    
    <event name="publish:end">
    <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
      <sites hint="list">
        <site s="1">YourSite</site>
      </sites>
    </handler>
    <handler type="YourNameSpace.DictionaryCacheClearer, YourAssembly" method="ClearCache" />
    </event>
    

    Other fix you find it here: https://community.sitecore.net/developers/f/8/t/173