CacheExpirationPolicy Property

XmlDataSource.CacheExpirationPolicy Property


Gets or sets the cache expiration policy that is combined with the cache duration to describe the caching behavior of the cache that the data source control uses.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract CacheExpirationPolicy : DataSourceCacheExpiry with get, set
override CacheExpirationPolicy : DataSourceCacheExpiry with get, set

Property Value

Type: System.Web.UI.DataSourceCacheExpiry

One of the DataSourceCacheExpiry values. The default cache expiration policy setting is Absolute.

The behavior of the cache is governed by a combination of the CacheDuration and CacheExpirationPolicy settings. If the CacheExpirationPolicy is set to Absolute, the XmlDataSource caches data on the first data retrieval operation, holds it in memory for the amount of time specified by CacheDuration, and invalidates it after the time has lapsed. The cache is then refreshed upon the next operation. If the CacheExpirationPolicy is set to Sliding, the data source control caches data on the first data retrieval operation, but resets the time window that it holds the cache for upon each subsequent operation. The cache will expire only if there is no activity for a time equal to the CacheDuration since the last data retrieval.

The following code example demonstrates how to enable caching when using the XmlDataSource control to display data contained in an XML file. Caching is enabled when the EnableCaching property is set to true and the CacheDuration is set to the number of seconds that the data is cached by the data source control.

No code example is currently available or this language may not be supported.

The XML file in the code example has the following data:

     <book title="Secrets of Silicon Valley" author="Sheryl Hunter"/>
     <book title="Straight Talk About Computers" author="Dean Straight"/>
     <book title="You Can Combat Computer Stress!" author="Marjorie Green"/>                
     <book title="Silicon Valley Gastronomic Treats" author="Innes del Castill"/>

.NET Framework
Available since 2.0
Return to top
© 2016 Microsoft