NCache 4.3 - Online Documentation

View State Caching and Java Script Minification

 
Following are the two steps that you need to follow in order to use content optimization feature of NCache:
 
Step 1: Update/Configure app browser file:
 
  • Create an App browser file in your asp.net application. It will be created under the directory of App_browsers.
  • Plug page adapters in the app browser file as following:
     
    <browser refID ="Default">
    <controlAdapters>
    <adapter controlType = "System.Web.UI.Page" adapterType = "Alachisoft.NCache.Adapters.PageAdapter"/>
    </controlAdapters>
    </browser>
     
    Here page adapter is plugged at page level. You can also plug it at any control level for which you want to cache the view state.
 
Step 2: Update/Configure web.config file:
 
  • You need to add the following assembly reference in compilation section of web.config file.
     
    <compilation defaultLanguage = "c#" debug = "true" targetFramework = "4.0">
    <assemblies>
    <add assembly = "Alachisoft.NCache.Adapters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cff5926ed6a53769"/>
    </assemblies>
    </compilation>
     
  • You need to register a web config section which contains the settings/properties in web.config file.
     
    <configSections>
    <sectionGroup name = "ncContentOptimization">
    <section name = "settings" type = "Alachisoft.NCache.ContentOptimization.Configurations.ContentSettings" allowLocation = "true" allowDefinition = "Everywhere"/>
    </sectionGroup>
    </configSections>
     
  • Add the actual setting/configuration section as follows:
     
    <ncContentOptimization>
    <settings enableMinification = "true" enableViewstateCaching = "true"
    groupedViewStateWithSessions = "true" viewstateThreshold = "0" enableTrace = "true">
    <cacheSettings cacheName = "mycache" maxViewStatesPerSession = "10" >
    <expiration type="Sliding" duration = "300"/>
    </cacheSettings>
    </settings>
    </ncContentOptimization>
     
  • enableMinification: Enable/disable the Java script minification.
  • enableViewstateCaching: Enable/disable the ViewState caching.
  •  
 
Register the http handler in the HttpHandlers section of web.config as following:
 
<add verb = "GET,HEAD" path = "NCResource.axd" validate = "false" type = "Alachisoft.NCache.Adapters.ContentOptimization.ResourceHandler, Alachisoft.NCache.Adapters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cff5926ed6a53769"/>
 
Through querystring parameter "rpo=off", user can quickly turn off CSS and JS minification without modifying web.config. This facility is provided to the users to analyze the page load time with and without content optimization.
 
 
See Also

 
© Copyright  2014 Alachisoft. All rights reserved.