Output Cache Provider
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.

Output Cache Provider for Azure In-Role Cache

Updated: August 25, 2015

Microsoft recommends all new developments use Azure Redis Cache. For current documentation and guidance on choosing an Azure Cache offering, see Which Azure Cache offering is right for me?

The Microsoft Azure output cache provider is an out-of-process storage mechanism for output cache data. This data is specifically for full HTTP responses (page output caching). The provider plugs into the new output cache provider extensibility point that was introduced in ASP.NET 4.

For a sample of output caching, see Caching Session State and Output Caching Sample.

For this release, the output cache provider does not support Web Forms control-level output caching.

The following list describes the benefits of storing output cache data out-of-process:

  • Developers can store larger amounts of output cache data because the only effective upper boundary on the quantity of data that can be cached is the cumulative amount of memory available to the cache cluster.

  • Output cache data is not lost when a web application is recycled. Since the output cache data is stored externally outside of the IIS worker process, output cache data survives ASP.NET application restarts.

  • It can use compression through cache client properties.

  1. First, configure a cache to use with the ASP.NET provider. You can host caching with a co-located topology or with a dedicated role.

  2. Use NuGet to add caching support to your ASP.NET project in Visual Studio. For instructions, see How to: Prepare Visual Studio to Use Azure In-Role Cache.

    These steps require the latest NuGet Package Manager (version 2.1.31002.9028 or higher). To install the latest NuGet Package Manager, go to http://go.microsoft.com/fwlink/?LinkId=240311.

  3. Remove any existing caching element that configures output caching. Do not remove the commented caching section that was added by the NuGet package.

  4. In the web.config file, uncomment the caching section.

        <!-- Azure Caching output caching provider -->
          <outputCache defaultProvider="AFCacheOutputCacheProvider">
              <add name="AFCacheOutputCacheProvider" 
                type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache"
                applicationName="AFCacheOutputCache" />

The following list provides optional configuration changes that affect the output cache provider.

  • Change the targeted named cache with the cacheName attribute of the add element.

  • Change the source of the cache client settings with the dataCacheClientName attribute of the add element. Set this attribute to the name of an existing dataCacheClient section in the web.config file.

  • Modify the behavior of the cache client by changing the settings in the associated dataCacheClient section. For example, enable compression with the isCompressionEnabled attribute.

    <dataCacheClient name="default" isCompressionEnabled="true">
    For a list of available configuration options, see In-Role Cache Client Configuration Settings (Web.config). Note that the ASP.NET providers for caching do not support binary or custom serialization types.

  • Change the settings for the output cache provider. For a list of available configuration options, see ASP.NET Output Cache Provider Configuration Settings in Azure In-Role Cache.

See Also

© 2015 Microsoft