ASP. Net. config-configuration element caching

Source: Internet
Author: User

Remember before writing the cache demo, it seems to have configured this element, as if this element is still a bit common.

I. List of caching elements

Elements Description

Cache

Defines the global application cache settings.

An optional element.

OutputCache

Specifies the application-wide output cache settings.

An optional element.

outputCacheSettings

Specifies the output-cache settings that can be applied to pages in the application.

An optional element.

SqlCacheDependency

Configures the SQL cache dependency for the ASP.

An optional element.

1. Cache

    Property

Characteristics

Description

Disablememorycollection

Gets or sets a value that indicates whether cache memory recycling is disabled when the computer is under memory pressure.

The optional Boolean attribute.

Disableexpiration

Gets or sets a value that indicates whether cache expiration is disabled. if disabled, the cache entry does not expire and background cleanup is not performed on expired cache entries.

An optional Boolean attribute.

privateBytesLimit

Gets or sets a value that indicates the maximum private byte size of an application before the cache starts flushing expired items and attempts to reclaim memory.  

Optional Int64 feature.

percentagePhysicalMemoryUsedLimit

Gets or sets a value that indicates the maximum percentage of physical memory that can be used by the computer before the cache starts refreshing the item and attempts to reclaim memory. set to 0 causes the item to be removed immediately after it is inserted.

optional  int32  feature.

Privatebytespolltime

Gets or sets a value that indicates the time interval between two polling application private bytes memory usage.

An optional TimeSpan attribute.

Position
caching, configuration-> system.web //This element is placed under <system.web> under <configuration> node

Example:

 <cache  Disablememorycollection = "false"  //does not prohibit memory reclamation disableexpiration = "false"  //cache does not expire privatebyteslimit  //when memory is to this value, it starts to reclaim memory percentagePhysicalMemoryUsedLimit = //when a program uses more than 60% of memory, it starts to recycle privatebytespolltime = " 00:01:00 "/> //1 seconds detects all memory sizes of the current program    

2, OutputCache

    Property

Characteristics

Description

enableOutputCache

The optional Boolean attribute.

Enables/disables page output caching.

If disabled, the page is not cached, regardless of whether it has programmatic or declarative settings.

The default value is true.

Enablefragmentcache

The optional Boolean attribute.

Enables/disables application fragment caching.

If disabled, the page is not cached regardless of whether the @ OutputCache directive or the cache profile is used. includes a cache control header that indicates that the upstream proxy server and browser clients should not attempt to cache page output.

The default value is false.

Sendcachecontrolheader

The optional Boolean attribute.

Gets or sets a value that indicates whether the Cache-control:private header is sent by the output cache module by default.

The default value is false.

Omitvarystar

boolean attribute. " > optional  boolean  feature.

vary: *" headers in the response. " > allow/Disallow sending HTTP "vary: *" header in response.  vary: *" header is sent for output cached pages. " The default setting is False, which indicates that the "vary: *" header is sent for the output cache page.

false." The default value is  false.

Defaultprovider

An optional string attribute.

Gets or sets the default output-cache provider.

The default value is "Aspnetinternalprovider". This is the memory cache provided by ASP.

Position

caching, Configuration-> system.web

    Example

<OutputCacheenableOutputCache= "true"  //Enable cache page Enablefragmentcache = "true"  //Enable program fragment cache Sendcachecontrolheader = "true"  //cache-control:private  header is sent by the output cache module Omitvarystar = "false "//indicates that the" vary: * "header is sent for the output cache page.  Defaultprovider=" Aspnetinternalprovider "> //output cache provider. </outputcache>  

    child element providers element

Add

An optional element.

Adds a custom output-cache provider to the collection of available providers for the application.

Clear

An optional element.

Removes all configured output-cache providers from the collection of available providers for the application.

Remove

An optional element.

Removes the specified output-cache provider from the collection of application providers.

Example:

<providers>    <add     <</></providers> 

3.

    

    4, SqlCacheDependency

Characteristics

Description

Enabled

The required Boolean attribute.

Indicates whether the change is polled.

Polltime

Optional Int32 feature.

Sets the frequency at which the SqlCacheDependency class instance polls for database table changes. This value corresponds to the number of milliseconds between polling for two consecutive times. it cannot be set to a value less than 500 milliseconds.

The default value is 1 minutes.

Child elements

Elements

Description

Databases

An optional element.

Contains one or more named SQL connections that can be used by an instance of the SqlCacheDependency class.

    Position

caching, Configuration-> system.web

    SQL Dependent Cache configuration

    <compilation debug= "True" targetframework= "4.0"/>    <caching>      <sqlcachedependency enabled= " True "Polltime=" >//This line configuration means that the database cache is turned on and the polling time is 1 seconds, so that you can quickly see the effect of the change        <databases>          <add Connectionstringname= "ApplicationServices" name= "con"/>        </databases>      </sqlcachedependency >    </caching>

Iii. examples

  Example page output cache configuration:

<outputCacheSettings><outputcacheprofiles > <add name= "serveronly"  duration = " //Expiration Time is 60 second Var Ybycustom= "browser"  location = "Server" /> </< Span style= "color: #800000;" >outputcacheprofiles></ outputcachesettings>      

ASP. config-config element caching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.