Export (0) Print
Expand All
Expand Minimize

CachingSection Class [IIS 7 and higher]

IIS 7.0

Configures output and kernel caching.

class CachingSection : ConfigurationSectionWithCollection

The following table lists the methods exposed by the CachingSection class.

Name

Description

Add

(Inherited from ConfigurationSectionWithCollection.)

Clear

(Inherited from ConfigurationSectionWithCollection.)

Get

(Inherited from ConfigurationSectionWithCollection.)

GetAllowDefinition

(Inherited from ConfigurationSection.)

GetAllowLocation

(Inherited from ConfigurationSection.)

Remove

(Inherited from ConfigurationSectionWithCollection.)

RevertToParent

(Inherited from ConfigurationSection.)

SetAllowDefinition

(Inherited from ConfigurationSection.)

SetAllowLocation

(Inherited from ConfigurationSection.)

The following table lists the properties exposed by the CachingSection class.

Name

Description

Enabled

A read/write boolean value. true if the output cache is enabled; otherwise, false. If the output cache is disabled, no response output caching or kernel caching will occur. The default is true.

EnableKernelCache

A read/write boolean value. true if kernel caching is enabled; otherwise, false. The default is true.

Location

(Inherited from ConfigurationSection.) A key property.

MaxCacheSize

A read/write uint32 value that specifies the maximum size, in megabytes, of the output cache. The default is 0. A value of 0 means that the cache memory size is managed automatically. A size of MaxValue means that there is no limit on cache size.

NoteNote:
This setting is effective only at the level of the ApplicationHost.config file. If you set this property at a lower level, it will have no effect.

MaxResponseSize

A read/write uint32 value that specifies the maximum size, in bytes, of a response that can be stored in the output cache. The default is 262144 (256KB). A setting of 0 means no limit.

NoteNote:
This setting is effective only at the level of the ApplicationHost.config file. If you set this property at a lower level, it will have no effect.

Path

(Inherited from ConfigurationSection.) A key property.

Profiles

A CachingProfileSettings value that configures caching for specific request extensions.

SectionInformation

(Inherited from ConfigurationSection.)

This class contains no subclasses.

The following example displays properties in the CachingSection object for the default Web site, including the CachingProfileSettings values in the Profiles array property. Two helper functions are provided to display text for the Policy, KernelCachePolicy, and Location enumerations.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

' Get the CachingSection for the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "CachingSection", oSection

' Display the path and location.
Wscript.Echo "Path: " & oSection.Path
Wscript.Echo "Location: " & oSection.Location
Wscript.Echo 

' Display other non-array CachingSection properties.
WScript.Echo "Enabled: " & oSection.Enabled
Wscript.Echo "EnableKernelCache: " & oSection.EnableKernelCache
Wscript.Echo "MaxCacheSize: " & oSection.MaxCacheSize
Wscript.Echo "MaxResponseSize: " & oSection.MaxResponseSize
Wscript.Echo 

' Display the caching profiles from the Profiles property.
For Each oCachingProfileElement In oSection.Profiles.Profiles
    Wscript.Echo 
    WScript.Echo "[ " & oCachingProfileElement.Extension & _
        " ] Caching Profile"
    WScript.Echo "-----------------------------------"
    WScript.Echo "Duration: " & oCachingProfileElement.Duration
    WScript.Echo "KernelCachePolicy: " & _
        CachePolicyText(oCachingProfileElement.KernelCachePolicy)
    WScript.Echo "Location: " & _
        LocationText(oCachingProfileElement.Location)
    WScript.Echo "Policy: " & _
        CachePolicyText(oCachingProfileElement.Policy)
    WScript.Echo "VaryByHeaders: " & _
        oCachingProfileElement.VaryByHeaders
    WScript.Echo "VaryByQueryString: " & _
        oCachingProfileElement.VaryByQueryString
    WScript.Echo             
Next

' Provide text for KernelCachePolicy and Policy enumeration values.
Function CachePolicyText(enumval)
Select Case enumval
    Case 0
        CachePolicyText="DontCache"
    Case 1
        CachePolicyText="CacheUntilChange"
    Case 2
        CachePolicyText="CacheForTimePeriod"
    Case Else
        CachePolicyText="Undefined enumeration value"
End Select
End Function

' Provide text for Location enumeration values.
Function LocationText(enumval)
Select Case enumval
    Case 0
        LocationText="Any"
    Case 1
        LocationText="Client"
    Case 2
        GetLocationText="Downstream"
    Case 3
        LocationText="Server"
    Case 4
        LocationText="None"
    Case 5
        LocationText="ServerAndClient"
    Case Else
        LocationText="Undefined enumeration value"
End Select
End Function

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

Community Additions

ADD
Show:
© 2015 Microsoft