Try Playground
Show / Hide Table of Contents

ASP.NET Output Cache Provider Overview

To configure NCache as ASP.NET Output Cache Provider, please follow the steps below:

Prerequisites

  • .NET
  • Legacy API
  • To configure ASP.NET Output Cache Provider install the following NuGet packages in your application based on your NCache edition:
    • Enterprise: AspNet.OutputCache.NCache
    • Professional: AspNet.OutputCache.NCache.Professional
  • To utilize the extension, include the following namespaces in your application in Startup.cs:
    • Alachisoft.NCache.OutputCacheProvider
  • The cache must be running.
  • For API details, refer to: NOutputCacheProvider, GetByTag.
  • Make sure that the data being added is serializable.
  • To ensure the operation is fail-safe, it is recommended to handle any potential exceptions within your application, as explained in Handling Failures.
  • To handle any unseen exceptions, refer to the Troubleshooting section.
  • Create a new Console Application.
  • Make sure that the data being added is serializable.
  • Add NCache References by locating %NCHOME%\NCache\bin\assembly\4.0 and adding Alachisoft.NCache.Web and Alachisoft.NCache.Runtime as appropriate.

Step 1: Register NCache as ASP.NET Output Cache Provider

To register NCache as ASP.NET Output Cache in Web.config of your application, under the section of system.web element add NCache Provider as a default provider, i.e.;

<!-- caching section group -->

<caching>
  <outputCache defaultProvider ="NOutputCacheProvider">
    <providers>
    <add name="NOutputCacheProvider" 
         type= "Alachisoft.NCache.OutputCacheProvider.NOutputCacheProvider, Alachisoft.NCache.OutputCacheProvider, Version=x.x.x.x, Culture=neutral, PublicKeyToken=cff5926ed6a53769" 
         cacheName="demoCache" 
         exceptionsEnabled="false"
         enableDetailLogs="false" 
         enableLogs="true" 
         writeExceptionsToEventLog="false"/>"
    </providers>
  </outputCache>
</caching>
Note

Replace Version=x.x.x.x with the actual NCache version that you have installed.

Configuration Members

Following are the ASP.NET Output Cache Provider configuration members:

Members Description
cacheName Specifies the name of the cache that has been configured through NCache Management Center. The application will use this cache for caching specified pages. It requires a String parameter and if no cache name is specified, a configuration exception will be thrown.
exceptionsEnabled It is an optional Boolean attribute that specifies whether exceptions from cache API are propagated to the page output. Setting this flag True is especially helpful during the development phase of the application since exceptions provide more information about the specific causes of failure. The default value is False.
enableLogs It is an optional Boolean attribute. When this flag is set to True, all important events are logged including exceptions, cache initialized, disposed, and session not found, etc. The default value is False.
enableDetailLogs It is an optional Boolean attribute. When this flag is set to True, the information that is useful for debugging purposes will be included in the logs. The default value is False.

Step 2: Add ASP.NET Output Cache Tag To Specific Pages

Add the below mentioned OutputCache tag to those pages whose output you want to cache. Its duration is specified in seconds.

<%@ OutputCache VaryByParam="ID" Duration="300">

Fetch Output Cache Data

Note

Tags are only available in NCache Enterprise.

Output cache data can be retrieved by NC_ASP.net_output_data tag. With this tag, it is easy to find data specific to Output Caching data.

  • .NET
  • Legacy API
Hashtable allOutputCacheData = cache.SearchService.GetByTag(new Tag("NC_ASP.net_output_data"));
Hashtable allOutputCacheData = cache.GetByTag(new Alachisoft.NCache.Runtime.Caching.Tag("NC_ASP.net_output_data"));

See Also

Using Output Cache with Custom Hooks
View State Caching
ASP.NET Core
Alachisoft.NCache.OutputCacheProvider

In This Article
  • Prerequisites
  • Step 1: Register NCache as ASP.NET Output Cache Provider
    • Configuration Members
  • Step 2: Add ASP.NET Output Cache Tag To Specific Pages
  • Fetch Output Cache Data
  • See Also

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top