Friday, November 05, 2004 - Posts

OutputCache Profiles in Whidbey

OutputCache profiles is a new feature in whidbey, which allows you to centrally maintain outputcache settings of all your cached files. In ASP.NET 1.x, if you want to change duration for your cached files. You need to open all the files and change the duration property in the output cache directive. But in ASP.NET 2.0, you can just change it in one central place(web.config). It will be reflected in all the cached pages. You need to mention a new Cacheprofile property in outputcache page directive of  all the cached pages for this to work. For example,

<%@ OutputCache CacheProfile="CacheFor60Seconds" VaryByParam="name" %>

Other properties like duraction for Outputcache is mentioned in web.config,

<?xml version="1.0"?>
<configuration>
    <system.web>
        <caching>
            <outputCacheSettings>
                <outputCacheProfiles>
                    <add name="CacheFor60Seconds" duration="60" />
                </outputCacheProfiles>
            </outputCacheSettings>
        </caching>    
    </system.web>
</configuration>

This duration value(60 seconds) is reflected in all the pages where outputprofile name is mentioned as “CacheFor60Seconds”. Like this you can create  many outputprofile's in your web.config depending upon your requirements. Then you can group your caching file and set the Cacheprofile property for that pages correspondingly.

 

with 0 Comments