asp.net.ph

Skip Navigation Links

<caching> cache Element

ASP.NET Syntax   ASP.NET Configuration Sections


Defines application-wide cache settings for an ASP.NET Web application.configuration Element (General Settings Schema)
  system.web Element (ASP.NET Settings Schema)
    caching Element (ASP.NET Settings Schema)
      cache Element for caching (ASP.NET Settings Schema)

<cache disableMemoryCollection="true|false" 
       disableExpiration="true|false" 
       privateBytesLimit="number" 
       percentagePhysicalMemoryUsedLimit="number" 
       privateBytesPollTime="HH:MM:SS" />

Collapse imageAttributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

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

Optional Boolean attribute.

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 consumed by an application before the cache starts flushing expired items and attempting to reclaim memory This memory usage includes both memory used by the cache as well as the normal memory usage of the running application. A setting of zero indicates that ASP.NET will use its own heuristics for determining when to start reclaiming memory.

privateBytesPollTime

Optional TimeSpan attribute.

Gets or sets a value indicating the time interval between polling for the application’s private bytes memory usage.

Child Elements

None.

Parent Elements

Element Description

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.

Collapse imageRemarks

Collapse imageDefault Configuration

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.

  CopyCode imageCopy Code
<cache disableMemoryCollection = "false" 
  disableExpiration = "false" 
  privateBytesLimit = "0" 
  percentagePhysicalMemoryUsedLimit = "89" 
  privateBytesPollTime = "00:02:00" />

<cache disableMemoryCollection="false" 
  disableExpiration="false" privateBytesLimit="0" 
  percentagePhysicalMemoryUsedLimit="90" 
  privateBytesPollTime="00:02:00" />

Collapse imageExample

The following example sets the global cache settings for an ASP.NET application.

  CopyCode imageCopy Code
<cache disableMemoryCollection = "false" 
  disableExpiration = "false" 
  privateBytesLimit = "20971520" 
  percentagePhysicalMemoryUsedLimit = 60" 
  privateBytesPollTime = "00:01:00"/>
andCollapse(sectionToggle0) tabIndex=0>Collapse imageDefault Configuration

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.

  CopyCode imageCopy Code
<cache disableMemoryCollection = "false" 
  disableExpiration = "false" 
  privateBytesLimit = "0" 
  percentagePhysicalMemoryUsedLimit = "89" 
  privateBytesPollTime = "00:02:00" />

<cache disableMemoryCollection="false" 
  disableExpiration="false" privateBytesLimit="0" 
  percentagePhysicalMemoryUsedLimit="90" 
  privateBytesPollTime="00:02:00" />

Collapse imageExample

The following example sets the global cache settings for an ASP.NET application.

  CopyCode imageCopy Code
<cache disableMemoryCollection = "false" 
  disableExpiration = "false" 
  privateBytesLimit = "20971520" 
  percentagePhysicalMemoryUsedLimit = 60" 
  privateBytesPollTime = "00:01:00"/>
See Also

outputCache Element   outputCacheSettings Element   sqlCacheDependency Element   CacheSection Class



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note