SQLAsyncOutputCacheProvider is an asynchronous SQL Server-based output cache provider for ASP.NET. It enables storing ASP.NET output cache data in a SQL Server database, allowing for distributed caching across web farm scenarios.
- Asynchronous database operations for improved scalability via integration with OutputCacheModuleAsync
- Traditional or In-Memory OLTP tables for cache storage
- .NET Framework 4.6.2 or later (Full framework - not .NET Core)
- SQL Server 2014 (12.0) or later for In-Memory OLTP support
-
Target your application to .NET Framework 4.6.2 or later
The
OutputCacheProviderAsyncinterface was introduced in .NET Framework 4.6.2, therefore you need to target your application to .NET Framework 4.6.2 or above in order to use the Async OutputCache Module. Download the .NET Framework 4.6.2 Developer Pack if you do not have it installed yet and update your application'sweb.configtargetFramework attributes as demonstrated below:<system.web> <compilation debug="true" targetFramework="4.6.2"/> <httpRuntime targetFramework="4.6.2"/> </system.web>
-
Add NuGet packages
Use the NuGet package manager to install:
- Microsoft.AspNet.OutputCache.OutputCacheModuleAsync
- Microsoft.AspNet.OutputCache.SQLAsyncOutputCacheProvider
This will add a reference to the necessary assemblies and configuration similar to the following into the
web.configfile.<system.web> <caching> <outputCache defaultProvider="SQLAsyncOutputCacheProvider"> <providers> <add name="SQLAsyncOutputCacheProvider" connectionStringName="DefaultConnection" UseInMemoryTable="[true|false]" type="Microsoft.AspNet.OutputCache.SQLAsyncOutputCacheProvider.SQLAsyncOutputCacheProvider, Microsoft.AspNet.OutputCache.SQLAsyncOutputCacheProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </providers> </outputCache> </caching> </system.web>
-
Further Configuration
Be sure that
web.configincludes both the connection string and theOutputCacheModuleAsyncconfiguration:<configuration> <connectionStrings> <add name="SQLOutputCache" connectionString="Data Source=<myserver>;Initial Catalog=OutputCache;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.webServer> <modules> <remove name="OutputCache" /> <add name="OutputCache" type="Microsoft.AspNet.OutputCache.OutputCacheModuleAsync, Microsoft.AspNet.OutputCache.OutputCacheModuleAsync" preCondition="integratedMode" /> </modules> </system.webServer> </configuration>
- Initial release.