Step 2: Edit Web.Config or Machine.Config
|
This feature is not available in NCache Express and Professional edition.
|
After you have configured the cache and have named it "myQSPartitionedCache", you now need to configure your ASP.NET application to use the Output Cache Module that is provided with NCache installation. To do so, you must edit web.config file.
Please follow these steps for enabling NCache Output Caching Module to transparently save and retrieve rendered pages.
-
Register NOutputCache as httpmodule inside <system.web> in web.config file.
For Enterprise and Professional Edition:-
<httpModules>
<add name = "Alachisoft.NCache.Web.NOutputCache" type = "Alachisoft.NCache.Web.NOutputCache.NOutputCache,
Alachisoft.NCache.OutputCache, Version=x.x.x.x, Culture=neutral, PublicKeyToken=cff5926ed6a53769"/>
</httpModules>
For Open Source Edition:-
<httpModules>
<add name = "Alachisoft.NCache.Web.NOutputCache" type = "Alachisoft.NCache.Web.NOutputCache.NOutputCache,
Alachisoft.NCache.OutputCache, Version=x.x.x.x, Culture=neutral, PublicKeyToken=1448e8d1123e9096"/>
</httpModules>
|
Replace version “x.x.x.x” with the actual NCache version that you have.
|
2. Register 'ncache' configuration section in the <configSections> of the web.config as follows:
For Enterprise and Professional Editions:-
<configSections>
<section name = "ncache" type = "Alachisoft.NCache.Web.NOutputCache.NCacheSection, Alachisoft.NCache.OutputCache, Version=x.x.x.x, Culture=neutral, PublicKeyToken=cff5926ed6a53769"/>
</configSections>
For Open Source Edition:-
<configSections>
<section name = "ncache" type = "Alachisoft.NCache.Web.NOutputCache.NCacheSection, Alachisoft.NCache.OutputCache, Version=x.x.x.x, Culture=neutral, PublicKeyToken=1448e8d1123e9096"/>
</configSections>
|
Replace version “x.x.x.x” with the actual NCache version that you have.
|
3. Then add actual <ncache> section in <configuration> section of web.config holding information of pages to be cached.
<ncache>
<outputCacheSettings cacheName = "myQSPartitionedCache" clientCacheName = "" exceptionsEnabled = "true" enableLogs = "false" enableClientCacheSync = "false">
<outputCachePages>
<add name = "/NOutputCacheSample/main.aspx" enabled = "true" requestType = "post" duration = "20" varyByParam = "cbxCustomerName" varyByHeader = "Connection" varyByCustom = "browser"/>
</outputCachePages>
</outputCacheSettings>
</ncache>
For detailed description of different key-value pairs specified above, please see
Using Output Cache.
See Also