Leverage Azure Cache Services with Sitecore

When I first started to look at hosting Sitecore on Windows Azure using the module provided by Sitecore I noticed that the default setup is using in-role caching. This means that a portion of your web role’s memory will be dedicated to caching and cannot be used to serve web requests. Some people might say ‘no problem’ I just scale out if I have the need to handle more requests. In essence that’s true, but based on your solutions’ needs this could come at a cost. Hence I was wondering whether there were any alternative options available within Windows Azure.

Windows Azure offers various caching options:

  1. In-role Cache
  2. Managed Cache Service
  3. Azure Redis Cache

Option 2 and 3 are Services that allow you to take caching off your web roles which might be cost beneficial depending on your requirements. Using a dedicated caching service is sometimes cheaper and could work better in terms of scalability.

In this blog post I am going to describe how Azure Redis Cache can be configured in Sitecore but the same way you could use the Managed Cache Service.

Configure a new Redis cache in Windows Azure


I have chosen the Standard tier that comes with 1GB and replication. Based on your needs and the number of items that you have in your Sitecore solution you might want to consider another plan.

Change Sitecore Azure settings

Ok, this is were the interesting stuff comes into play.

Navigate to ‘sitecore/system/modules/azure/{your-deployment}/{azure-region}/Editing01/Role01/Production’.

Edit the following field ‘[Do not edit!] – Global Web Config Patch (These are the global web config patches that will always be applied to every deployment)’:

  1.  Replace this line:
    <add name="DistributedCacheSessionStateStoreProvider"
         type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
         dataCacheClientName="default" />

    with the following line:

    <add name="DistributedCacheSessionStateStoreProvider"
         retryTimeoutInMilliseconds="20" />

    make sure you update the host attribute and the accessKey attribute

  2. Remove the following line:
    <section name="dataCacheClients"
             type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core"
             allowDefinition="Everywhere" />
  3. Remove the following line:
    <xsl:param name="pDataCacheClients">
          <dataCacheClient name="default" isCompressionEnabled="false">
            <autoDiscover isEnabled="true" identifier="SitecoreWebRole" />
            <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
          <crashDump dumpLevel="Off" dumpStorageQuotaInMB="100" scheduledTransferPeriodInMinutes="5" />
  4. Remove the following line:
    <xsl:copy-of select="$pDataCacheClients" />

Install Redis NuGet package

In your website solution install the RedisSessionStateProvider package from NuGet.


Now it’s time to build, publish and re-deploy your Sitecore solution to Windows Azure.

Leave a Reply

Your email address will not be published. Required fields are marked *