LibrarySites.Banner

Sitecore Output Cache Clearing Optimization (5/8): The custom:publish:end:remote Event | John West | Sitecore Blog

This entry about the custom:publish:end:remote event used to pass custom parameters to a remote event is part of a series of blog posts about a custom approach to clearing output caches for managed sites with the Sitecore ASP.NET web Content Management System (CMS) and Experience Platform (XP). For more information, see the Resources section at the end of this blog post.

To address distributed publishing, this solution seems to require that we pass custom parameters to a remote event. Luckily, Benjamin Vangansewinkel has already done the hard work for us.

First, the CustomPublishEndRemoteEvent class that represents the remote event. This class must have the [DataContract] attribute and in our case inherits from the default PublishEndRemoteEvent. This class has the following properties:

  • OutputCacheClearingOptions: This property named after its type has the [DataMember] attribute, which seems to be required for serializing parameters for remote events.
  • EventName: This is just the custom:publish:end:remote string.
  • Raise(): This method could clear the caches, but actually raises the custom:publish:end:remote to support the remote event paradigm. Another post in this series describes actual trapping this event to clear the output caches.

I was thinking that the keys that go into the cache to indicate when this process last cleared those caches could include identifiers such custom:publish:end:remote or indexing:end, to separate intervals for different types of events or otherwise.

This solution includes the CustomPublishEndRemoteEventArgs class that inherits from the default PublishEndRemoteEventArgs, which implements an interface and inherits from System.EventArgs. My project shows no usages of the CustomPublishEndRemoteEventArgs, but something apparently wires this type of argument to CustomPublishEndRemoteEvent. This class has a single OutputCacheClearingOptions property named after its type to access cache clearing options for the current operation.

Finally, we need the RegisterCustomPublishEndRemoteEvent hook to specify that the Raise method of the CustomPublishEndRemoteEvent class triggers a remote publishing end event.

Resources