2

Whenever I edit a dictionary phrase in the Content Editor, after I hit save, the change is reflected in the Experience Editor, which is great. However, I want to see this change in my web database as well, so I hit publish -> publish item and it publishes the item from master to web.

The issue is that it sometimes takes up to 8 publishes before the change is finally in my prod db.

It seems to be related with the dictionary cache not being updated properly.

Has anyone experienced a similar issue? Is there a solution to this?

2
  • What is your sitecore version? Sep 4, 2019 at 19:23
  • @HishaamNamooya Sitecore 9. I was reading that this issue should be fixed in Sitecore 9, but I guess for some reason I'm still getting it :/
    – Gary Chiu
    Sep 4, 2019 at 19:55

1 Answer 1

1

Base on the comments above, you'll require to create an event handler which will reset the cache of the dictionary. The event handler will be executed on the events publish:end and publish:end:remote.

If I am not mistaken, the items are available on the target database (web) after publish but it reads the dictionary from a file (.dat). So, it is the file that is still not yet updated.

I haven't yet jump into a deep dive on how the dictionary cache clear works but out of my mind, I think it is periodically updating the file, say every minute or 2.

Code Snippet

using System;
using Sitecore.Diagnostics;
using Sitecore.Globalization;

public class ResetDictionaryCache
{
    public void DictionaryClearCache(object sender, EventArgs args)
    {
        Translate.ResetCache();
        Log.Info("Dictionary Cache has been reset", this);
    }
}

Once that you have implemented the ResetDictionaryCache event handler, you will need to create a config patch for the publish:end and publish:end:remote.

Config Patch

<event name="publish:end">
    <handler type="Your.Namespace.ResetDictionaryCache, YourAssemblyName" method="DictionaryClearCache" />
</event>

<event name="publish:end:remote">
    <handler type="Your.Namespace.ResetDictionaryCache, YourAssemblyName" method="DictionaryClearCache" />
</event>

You can also use the overload method ResetCache(bool removeFileCache). Just pass it true and it will delete the file and then it will get rebuilt.

You'll still need the above if you are experiencing the below issues:

  • Dictionary items showing Key value instead of Phrase text
  • Dictionary cache not getting updated in remote instances such as CD servers
  • Dictionary entry shows incorrect value by Translate.Text(“Keyword”) with Fallback language item turned on

Reference: Troubleshooting Issues with Sitecore Dictionary in Multi Lingual Solutions

3
  • Would this have an impact on the performance of the CD server?
    – Gary Chiu
    Sep 5, 2019 at 17:35
  • Not as far as i know because once the cache is re populated, it will read the value from the cache Sep 5, 2019 at 17:36
  • Makes sense. Thank you so much!
    – Gary Chiu
    Sep 5, 2019 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.