Scenario Of Using Caching In An ASP.NET Or ASP.NET MVC Application | AppFabric Tutorial | AppFabric Reference Guide

,
ASP.NET applications are among the most important clients for AppFabric Caching Services. As just described, the data stored in an ASP.NET Session object is an obvious candidate for caching. In fact, the service provides built-in support for this—the developer just sets a configuration option, and the Session object will be transparently stored in the cache cluster. Notice what this means: ASP.NET developers can get the benefits of caching without changing any of their code. This allows using replicated Web servers, each running an instance of the same ASP.NET application, without either storing session state in SQL Server or requiring sticky sessions. Below figure shows how this looks.


Figure: An ASP.NET application can use AppFabric Caching Services to store Session object data.

This simple scenario begins with the user supplying some information that the ASP.NET application stores in the Session object for this user (step 1). The Web server that handles this request has been configured to cache Session objects in an AppFabric Caching Services cluster, and so the user’s data is written to one or more cache servers (step 2). The next request from this user relies on the data supplied in step 1, but it’s handled by a different Web server (step 3). The ASP.NET code on this Web server refers to the same Session object, which transparently accesses the cache cluster to retrieve the data (step 4). This makes the information provided in step 1 available to the application once again. Notice that there’s no need to access the application database here, since the Session object wasn’t stored there, nor must the user access the same Web server instance for each request. The result is an ASP.NET application with better performance and improved scalability.