The XmlDataSource control automatically caches data when the following applies:
-
The EnableCaching property is set to true.
-
The CacheDuration property is set to a value greater than 0, which indicates the number of seconds that the cache stores data before the cache is invalidated.
Any change to the Data property or the contents of the file that contains the XML data causes the cache to be invalidated.
By default, the CacheDuration property is set to 0, which indicates an indefinite cache, and the data source will cache data until the XML file that it depends on is changed.
The behavior of the cache is governed by a combination of the duration and the CacheExpirationPolicy setting. If CacheExpirationPolicy is set to Absolute, the XmlDataSource control 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 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 only expire if there is no activity for a time equal to the CacheDuration since the last data retrieval.