Sitecore html cache not clearing on publish

Sitecore html cache not clearing on publish

So you've got separate content management and content delivery servers, but when you publish the change is only visible on the content management box.

A likely cause is that you've enabled some caching but haven't updated the config files to clear the cache on your content delivery server.

Sitecores config files contain a list of handlers for what should happen when the event publish:end and publish:end:remote are triggered. Publish end is for the content management server, whereas publish end remote is for your delivery servers. The handler we're interested in is Sitecore.Publishing.HtmlCacheClearer which contains a list of sites to have the cache's cleared on.

By default this will contain one entry for website, the default name given to your site in the sites config when you install sitecore. However you will have changed this if your solution supports multiple sites, or if you changed it as part of some future planning to support multiple sites. If your site is missing, just add it to the live (via a patch file of course)

1<!-- Html Cache clear on publish events -->
2<!-- Force FULL cache clear on publish-->
3<event name="publish:end">
4 <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache" patch:source="BaseSettings.config">
5 <sites hint="list">
6 <site>SiteOne</site>
7 <site>SiteTwo</site>
8 <site>SiteThree</site>
9 </sites>
10 </handler>
11</event>
12<!-- Html Cache clear on publish events -->
13<!-- Force FULL cache clear on publish-->
14<event name="publish:end:remote">
15 <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache" patch:source="BaseSettings.config">
16 <sites hint="list">
17 <site>SiteOne</site>
18 <site>SiteTwo</site>
19 <site>SiteThree</site>
20 </sites>
21 </handler>
22</event>

Note: in the sample above I have removed all other handlers to simplify the example. You should not remove these from your solution.

For more info on cache clearing and optimising it, see John Wests blog series on the subject here https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/sitecore-output-cache-clearing-optimization-1-8-introduction-john-west-sitecore-blog