I recently configured a CD and CM environment, where the CD's are isolated from the CM environment on their own machine. Is there a way to tell via the logs that the Html Cache has been cleared when I do a publish on the CM environment that affects the web database for the CD environment? Obviously I could just check via testing of the website, but that could be misleading.
2 Answers
Just for clarification of how HTML cache works, the remote CD servers need to know about the CM server publish event. That setting is EnableEventQueues. If it is set to true on the remote server, the remote listen for the CM end:publish event.
<setting name="EnableEventQueues" value="true"/>
Then on the CM server you need to make sure the publish:end event has the HtmlCacheClearer (method = ClearCache) handler.
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>website</site>
</sites>
</handler>
</event>
Finally in the log you can look for this log. It is the cache being cleared from the event end.
16812 19:06:53 INFO Job started: Publish 15296 19:06:53 INFO Job started: Publish to 'web' 15296 19:06:57 INFO HtmlCacheClearer clearing HTML caches for all sites (2). 15296 19:06:57 INFO HtmlCacheClearer done.
The last thing I will mention is that in some of the times when I needed info like this, on renderings that I have cached. I use this code to push all this cache info for the rendering into a HTML comment. This is written at the time the rendering was created and is stored in the cached HTML.
<!--
CacheKey = @Html.Sitecore().CurrentRendering.Caching.CacheKey
Cachable = @Html.Sitecore().CurrentRendering.Caching.Cacheable
Timeout = @Html.Sitecore().CurrentRendering.Caching.Timeout
VaryByData = @Html.Sitecore().CurrentRendering.Caching.VaryByData
VaryByDevice = @Html.Sitecore().CurrentRendering.Caching.VaryByDevice
VaryByLogin = @Html.Sitecore().CurrentRendering.Caching.VaryByLogin
VaryByParameters = @Html.Sitecore().CurrentRendering.Caching.VaryByParameters
VaryByQueryString = @Html.Sitecore().CurrentRendering.Caching.VaryByQueryString
VaryByUser = @Html.Sitecore().CurrentRendering.Caching.VaryByUser
Time = @System.DateTime.Now.ToShortDateString() - @System.DateTime.Now.ToLongTimeString()
-->
-
Will the log message be present in CD logs as well? One could argue that seeing it in the CM logs doesn't guarantee the event was properly handled by all CDs. Commented Nov 7, 2016 at 6:41
-
1Yes, the HtmlCacheClearer log messages will show in the CD log too.– KasakuCommented Nov 7, 2016 at 8:10
Add a comment into your html template (ascx/cshtml) containing the date. The comment will contain the time the component was cached.