Defines application-wide cache settings for an ASP.NET Web application.
<cache disableMemoryCollection="true|false" disableExpiration="true|false" privateBytesLimit="number" percentagePhysicalMemoryUsedLimit="number" privateBytesPollTime="HH:MM:SS" />
The following sections describe attributes, child elements, and parent elements.
Attribute
Description
disableMemoryCollection
Optional Boolean attribute.
Gets or sets a value indicating whether the cache memory collection that occurs when the machine is under memory pressure is disabled.
disableExpiration
Gets or sets a value indicating whether cache expiration is disabled. When disabled, cached items do not expire and background scavenging of expired cache items does not occur.
privateBytesLimit
Optional Int64 attribute.
Gets or sets a value indicating the maximum size of an application's private bytes before the cache starts flushing expired items and attempting to reclaim memory. This limit includes both memory used by the cache as well as normal memory overhead from the running application. A setting of zero indicates that ASP.NET will use its own heuristics for determining when to start reclaiming memory.
percentagePhysicalMemoryUsedLimit
Optional Int32 attribute.
Gets or sets a value indicating the maximum percentage of a machine's physical memory that can be used before the cache starts flushing items and attempt to reclaim memory. Notice that the limit applies to the total physical memory in use. A setting of 0 results in entries being removed immediately, as quickly as they are inserted.
privateBytesPollTime
Optional TimeSpan attribute.
Gets or sets a value indicating the time interval between polling for the application's private bytes memory usage.
None.
Element
configuration
The required root element in every configuration file used by the common language runtime and .NET Framework applications.
system.web
Specifies the root element for the ASP.NET configuration settings in a configuration file. Contains configuration elements that configure ASP.NET Web applications and control how the applications behave.
caching
Configures the cache settings for a Web application.
The following default cache element is not explicitly configured in the machine configuration file or in the root Web.config file, but is the default configuration returned by application in the .NET Framework version 2.0.
<cache disableMemoryCollection="false" disableExpiration="false" privateBytesLimit="0" percentagePhysicalMemoryUsedLimit="90" privateBytesPollTime="00:02:00" />
The following example sets the global cache settings for an ASP.NET application.
<cache disableMemoryCollection = "false" disableExpiration = "false" privateBytesLimit = "20971520" percentagePhysicalMemoryUsedLimit = 60" privateBytesPollTime = "00:01:00"/>
Configuration section handler
System.Web.Configuration..::.CacheSection
Configuration member
Cache
Configurable locations
Machine.config
Root level Web.config
Application level Web.config
Requirements
IIS version 5.0, 5.1 and 6.0
.NET Framework version 2.0
Visual Studio 2005