A semi-common Episerver requirement is to have a staging/live configuration. In this type of environment three servers exist, one server behind a firewall with the Episerver editor enabled and two loads balanced web facing boxes that have Episerver disabled.
This type of set-up creates one issue when someone updates a page on the editing server, how are those changes propagated to the live boxes? In today's guide, I'm going to cover how Episerver does this, the config code you'll need to add to your project in order to get it working and the different protocol options available
First off, cache invalidation between servers uses the Episerver event management system to distribute events. The event management system is configured through your web.config and can be configured to use either TCP or, UDP as the communication protocol. So this opens up the question, which one should I use?
When it comes to setting up your event management, you have two options of how the parent Episerver box talks to its children, UDP and TCP. UDP for those of you who can't remember their university days is a fire and forget protocol. Episerver will fire the cache invalidate command, however, it is not guaranteed that it will get to a child. UDP is a 'cheaper' option for sending events.
In older version of Epi (7 and below) a missed UDP call resulted in a full-cache invalidation, however, this is no longer the case. I've used both methods and they both seem to work. I did encounter a few TCP locked port issues with the continuous deployment pipeline using TCP when it tried to refresh the app pool. This also happened on the live server, so, potentially UDP might be the better route to try first. If you're not happy with it, you can always change it later, fairly painlessly.
Cache invalidation should just magically work when you enable the events management. In your web.config file, you'll need to add something in like this:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<add name="udpTransportCustom" type="Microsoft.ServiceModel.Samples.UdpTransportElement, EPiServer.Events" />
<service name="EPiServer.Events.Remote.EventReplication" behaviorConfiguration="DebugServiceBehavior">
<endpoint name="RemoteEventServiceEndPoint" contract="EPiServer.Events.ServiceModel.IEventReplication" bindingConfiguration="RemoteEventsBinding" address="soap.udp://MY-EDIT-SERVER-IP/RemoteEventService" binding="customBinding" />
<endpoint name="WebServer1" address="soap.udp://MY-WEB-SERVER-IP1/RemoteEventService" binding="customBinding" bindingConfiguration="RemoteEventsBinding" contract="EPiServer.Events.ServiceModel.IEventReplication" />
<endpoint name="WebServer2" address="soap.udp://MY-WEB-SERVER-IP2/RemoteEventService" binding="customBinding" bindingConfiguration="RemoteEventsBinding" contract="EPiServer.Events.ServiceModel.IEventReplication" />
<serviceDebug includeExceptionDetailInFaults="true" />
<udpTransportCustom multicast="True" />
<binding name="RemoteEventsBinding" portSharingEnabled="true">
<security mode="None" />
This configuration is using UDP to push changes between servers. In the client section, this is where you add your Editor server Url. The clients are your web server IP addresses. When configuring this for the first time, I suggest you log onto the box and manually try the URL's in a browser to make sure that the servers can talk to each other.
If you wanted to use TCP, you would need to change the 'soap.udp://' protocols within the Urls to 'net.tcp'. You'd also need to change the binding types, from 'customBinding' to netTcpBinding. For more information about this, you can see some further examples from the Episerver website, here.
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge