compareRevisions – very important!

When performing a publish action programmatically (from C#), you would usually call:

Sitecore.Publishing.PublishManager.PublishItem(itemToPublish, publishingTargets, languages, true, true);

The last parameter in this method call is a bool, compareRevisions.  If you set this parameter to false, Sitecore will perform a Republish.  If you set this parameter to true, Sitecore will perform a Smart Publish.

I ran into an issue this week, where, anytime my code ran, the application pool would spike to over 1 GB and publishing would no longer work from the Sitecore Content Editor (or Desktop).  While debugging my code, I found that I had set that parameter to false and when my code ran, it was asking Sitecore to republish about 1000 items.  Not a good idea.  It took me a while to figure it out but eventually I read the documentation again, http://sdn.sitecore.net/upload/sitecore6/64/content_api_cookbook_sc64_and_later-usletter.pdf, page 8, paragraph 4.  And there it was, “false means Republish, true means Smart Publish”.

So keep this mind – if you’re performing a publish action from code, consider whether or not you really need to perform a Republish.  If you conclude that you don’t, set the compareRevisions parameter to true and you will see the benefits of doing so.

Leave a Reply