Monday 8 March 2021

Sitecore dictionary item not getting phrase value intermittent issue

While working with Sitecore dictionary items, there are scenarios where not getting phrase value for dictionary items. And this issue intermittent(occasional type) not always facing this issue.

After spending time to find root cause of this issue - found that it's because of Dictionary Caching Issue.

And to resolve issue, there are several ways - can choose as per your fit.



1. Solve this issue by doing Global Change - Reset Dictionary Cache at application level

Please put below line of code in your application startup file

Sitecore.Globalization.Translate.ResetCache(true)


2. Solve this issue by Manual Steps - Reset Dictionary Cache

  • Shut down your app pool
  • Remove dictionary.dat from webroot/temp/ folder
  • Start your app pool again

3. Solve this issue by inserting custom pipeline - On Publish event reset dictionary cache.

update below config in Sitecore.config directly or add as new patch config inside (~/App_config/Include)

<event name="publish:end">

<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">

<sites hint="list">

<site>website</site>

</sites>

</handler>

<handler type="CustomNamespacePath, Customdll" method="CustomMethodName"/>

</event>


<event name="publish:end:remote">

<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">

<sites hint="list">

<site>website</site>

</sites>

</handler>

<handler type="CustomNamespacePath, Customdll" method="CustomMethodName"/>

</event>


After above config change, write logic to reset dictionary cache in your custom class  which will mention in above config file.




Hope this will help, please share your thoughts - incase of any better approach/feedback.

No comments:

Post a Comment