Louis-Charles Gagnon Blog

Microsoft Azure, Office 365 and SharePoint Blog

High Performance Cache - Azure Redis Cache (Output Cache and Session State)

One of Azure new preview feature is Azure Redis Cache. This feature allows you to speed up your .net application running Windows Azure. This feature is available since .NET 4.0




The Azure Redis Cache offers High Performance caching with this feature. This features helps your application become more responsive even as user load increases. It leverages the low-latency, high-throughput capabilities of the Redis engine. This separate, distributed cache layer allows your data tier to scale independently for more efficient use of compute resources in your application layer.

How to use it?

  • Login to Azure Portal
  • Add a ressource "Redis Cache"

High Performance - Output Cache

You can configure .net application or website (MVC or other) to use Output Cache via Redis Cache.
In order to do this, you must install the following nuget "RedisOutputCacheProvider" once the dll are loaded to the project, simply modify your web.config to use this feature:

<caching>
  <outputCache defaultProvider="RedisOutputCache">
    <providers>
          <add name="RedisOutputCache"
               type="Microsoft.Web.Redis.RedisOutputCacheProvider"
                port="6380"
                host="MYID.redis.cache.windows.net"
                accessKey="MYACCESSKEYINAZURE"
                ssl="true" />
    </providers>
  </outputCache>
</caching>
In order to use in your .aspx page, simply add the following to the page (at the top)

<%@ OutputCache Duration="60" VaryByParam="*" %>
For more information on this feature, view ASP.NET Output Cache Provider for Azure Redis Cache

High Performance - Session State

You can configure .net application or website (MVC or other) to use Session Cache via Redis Cache.
In order to do this, you must install the following nuget "RedisSessionStateProvider" once the dll are loaded to the project, simply modify your web.config to use this feature:

<sessionState mode="Custom" customProvider="RedisSessionProvider">
 <providers>
         <add name="RedisSessionProvider"
   type="Microsoft.Web.Redis.RedisSessionStateProvider"
   port="6380"
   host="MYHOST.redis.cache.windows.net"
   accessKey="MYAZUREKEY"
   ssl="true" />
      </providers>
</sessionState>
For more information on this feature, see ASP.NET Session State Provider for Azure Redis Cache

Shall you have any questions, need help or other, feel free to contact me lcg@ls2.ca
blog comments powered by Disqus