Click here to Skip to main content
14,975,411 members
Articles / Hosted Services / Azure
Article
Posted 14 Nov 2014

Tagged as

Stats

8.6K views
1 bookmarked

Leverage Azure Cache Services with Sitecore

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
14 Nov 2014CPOL2 min read
Out-of-the-box Sitcore Azure installation is using in-role caching. This article provides an alternative using Azure Cache services.

Introduction

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:

  • In-role Cache
  • Managed Cache Service
  • 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 article 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)':

Replace this line:

<add name="DistributedCacheSessionStateStoreProvider"
     type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
     cacheName="default"
     useBlobMode="true"
     dataCacheClientName="default" />

​<add cachename="default" datacacheclientname="default" name="DistributedCacheSessionStateStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" useblobmode="true">with the following line:

<add name="DistributedCacheSessionStateStoreProvider"
     type="Microsoft.Web.Redis.RedisSessionStateProvider"
     host="sitecore.redis.cache.windows.net"
     port="6379"
     accessKey="paste-your-access-key-in-here"
     ssl="false"
     throwOnError="false"
     retryTimeoutInMilliseconds="20" />

<add cachename="default" datacacheclientname="default" name="DistributedCacheSessionStateStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" useblobmode="true"><add accesskey="paste-your-access-key-in-here" host="sitecore.redis.cache.windows.net" name="DistributedCacheSessionStateStoreProvider" port="6379" retrytimeoutinmilliseconds="20" ssl="false" throwonerror="false" type="Microsoft.Web.Redis.RedisSessionStateProvider">make sure you update the host attribute and the accessKey attribute

Remove the following line:

<section name="dataCacheClients"
         type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core"
         allowLocation="true"
         allowDefinition="Everywhere" />

Remove the following line:

<xsl:param name="pDataCacheClients">
    <dataCacheClients>
      <dataCacheClient name="default" isCompressionEnabled="false">
        <autoDiscover isEnabled="true" identifier="SitecoreWebRole" />
        <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
      </dataCacheClient>
    </dataCacheClients>
    <cacheDiagnostics>
      <crashDump dumpLevel="Off" dumpStorageQuotaInMB="100" scheduledTransferPeriodInMinutes="5" />
    </cacheDiagnostics>
  </xsl:param>

Remove the following line:

<xsl:copy-of select="$pDataCacheClients" />

Install Redis NuGet package

In your website solution install the RedisSessionStateProvider package from NuGet.

Deploy

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Michael Ulmann
Architect Swissworx
Australia Australia
MCAD, MCPD Web Developer 2.0, MCPD Enterprise Developer 3.5

My company: Swissworx
My blog: Sitecore Experts

Hopp Schwiiz Smile | :)

Comments and Discussions

 
-- There are no messages in this forum --