HttpClientCache 类
公开 HTTP 客户端的缓存配置。
语法
class HttpClientCache : EmbeddedObject
方法
此类不包含任何方法。
属性
下表列出了 HttpClientCache
类公开的属性。
名称 | 描述 |
---|---|
CacheControlCustom |
一个读/写 string 值,指定要添加到响应中的 HTTP 1.1 Cache-Control 标头。 |
CacheControlMaxAge |
一个读/写 datetime 值,指定 HTTP 1.1 缓存控件的最大期限。 默认值为 1 天。 |
CacheControlMode |
一个读/写 sint32 枚举,指定要用于客户端缓存的模式。 后文的“注解”部分列出了可能的值。 |
HttpExpires |
一个读/写 string 值,以征求意见文档 (RFC) 1123 格式指定缓存的响应被视为过时的日期和时间。 |
子类
此类不包含子类。
注解
此类的实例包含在 StaticContentSection 类的 ClientCache
数组属性中。
下表列出了 CacheControlMode
属性可能的值。 默认值为 0 (NoControl
)。
值 | 关键字 | 说明 |
---|---|---|
0 | NoControl |
不向响应添加或 Cache-Control 或 Expires 标头。 |
1 | DisableCache |
将 Cache-Control: no-cache 标头添加到响应。 |
2 | UseMaxAge |
根据 CacheControlMaxAge 属性中指定的值向响应中添加 Cache-Control: max-age=<nnn> 标头。 |
3 | UseExpires |
根据 HttpExpires 属性中指定的日期向响应中添加 Expires: <date> 标头。 |
有关标头字段的详细信息,请参阅征求意见文档 (RFC) 2616“超文本传输协议 -- HTTP/1.1”。
有关日期和时间格式的详细信息,请参阅 RFC 1123,“Internet 主机的要求 - 应用和支持”。
示例
下面的示例显示 HttpClientCache
类的属性。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Retrieve the static content section.
Set oSection = oWebAdmin.Get("StaticContentSection.Path=" & _
"'MACHINE/WEBROOT/APPHOST',Location=''")
' Show the path and location.
WScript.Echo "Path: " & oSection.Path
WScript.Echo "Location: " & oSection.Location
WScript.Echo
Display the embedded HttpClientCache properties.
Set ohttpClientCache = oSection.ClientCache
WScript.Echo "HttpClientCache properties"
WScript.Echo "--------------------------"
WScript.Echo "CacheControlCustom: " & ohttpClientCache.CacheControlCustom
WScript.Echo "CacheControlMaxAge: " & ohttpClientCache.CacheControlMaxAge
WScript.Echo "CacheControlMode: " & _
GetCacheControlModeText(ohttpClientCache.CacheControlMode)
WScript.Echo "HttpExpires: " & ohttpClientCache.HttpExpires
' Provide text for CacheControlMode enumeration values.
Function GetCacheControlModeText(uint32Mode)
Select Case uint32Mode
Case 0
GetCacheControlModeText="NoControl"
Case 1
GetCacheControlModeText="DisableCache"
Case 2
GetCacheControlModeText="UseMaxAge"
Case 3
GetCacheControlModeText="UseExpires"
Case Else
GetCacheControlModeText="Unknown Mode"
End Select
End Function
继承层次结构
HttpClientCache
要求
类型 | 描述 |
---|---|
客户端 | - IIS 7.0(在 Windows Vista 上) - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10 上的 IIS 10.0 |
服务器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016 上的 IIS 10.0 |
产品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
MOF 文件 | WebAdministration.mof |
另请参阅
EmbeddedObject 类
StaticContentSection 类
CIM_DATETIME
Datetime.Parse 方法