Tuesday, 7 July 2015

Publishing in Multilingual Sitecore Sites - Reducing the Overhead

Have you noticed that when you publish one item in a single language Sitecore reports "Processed: 2"? Did you know that every time you publish, Sitecore secretly processes some items you didn't ask for? This is actually a feature designed to maintain the integrity of your content and that's obviously a good thing, but in practice I've often found it to be overkill. This post explains why Sitecore includes this behavior and should help you decide whether or not to disable it.

Sitecore's Publish pipeline contains a processor named AddLanguagesToQueue. Its purpose is to ensure that the items representing your selected languages (in sitecore/System/Languages) are themselves already published. If you've added a new language and forgot to publish it - no problem. It will happen automatically when you publish any item in that language. That's helpful, but it also creates an overhead every time you perform a publish:

Lets do a test. Here's what gets processed when you publish one item in Danish, English and German:

  • The Danish language item in Danish, English and German
  • The English language item in Danish, English and German
  • The German language item in Danish, English and German
  • The target item in Danish, English and German

So Sitecore actually processes 9 item versions before it even gets to the target item. No big deal, but what if you published the item in 30 languages? Then that number grows to 900!

I think it's safe to say that adding new languages to a Sitecore instance is not something you do every day. Making sure a new language is set up correctly is a one-off task that should be a pretty self contained activity. In my opinion we don't really need this safety net that Sitecore provides by default. We just need to make sure we publish everything that's required as and when we add a new language.

I've tried simply removing the AddLanguagesToQueue processor and so far haven't had any problems. Though you'll only see any real benefit in sites that have lot's of languages, I think this is definitely worth keeping in mind for those situations. It can drastically reduce the number of processed items.