I'm trying to add site name on list of sites so that HTML cache gets cleared on publish:end:remote
event.
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site patch:after="*[@site]">mysite</site>
</sites>
</handler>
<handler type="Sitecore.Publishing.RenderingParametersCacheClearer, Sitecore.Kernel" method="ClearCache"/>
</event>
However it isn't working as expected. I did googling and didn't find anything on how we can patch before or after an element. Most of the examples are on/before attribute etc.
Thanks.
If you want to patch a node without attributes, you can select the text() of the node to compair. before or after. see this Example:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites>
<site patch:before="site[./text()='website']">plop3</site>
</sites>
</handler>
</event>
</events>
</sitecore>
</configuration>
A different approach to your issue. With a patch delete you can clear the list and build your list from scratch.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<patch:delete />
</sites>
<sites hint="list">
<site>website</site>
<site>anotherwebsite</site>
</sites>
</handler>
</event>
</events>
</sitecore>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With