HttpWebRequest.DefaultCachePolicy 属性


获取或设置此请求的默认缓存策略。Gets or sets the default cache policy for this request.

 static property System::Net::Cache::RequestCachePolicy ^ DefaultCachePolicy { System::Net::Cache::RequestCachePolicy ^ get(); void set(System::Net::Cache::RequestCachePolicy ^ value); };
public static System.Net.Cache.RequestCachePolicy DefaultCachePolicy { get; set; }
member this.DefaultCachePolicy : System.Net.Cache.RequestCachePolicy with get, set
Public Shared Property DefaultCachePolicy As RequestCachePolicy


一个 HttpRequestCachePolicy,它指定当没有其他策略适用时对此请求有效的缓存策略。A HttpRequestCachePolicy that specifies the cache policy in effect for this request when no other policy is applicable.


设置此属性将为 HTTP 和 HTTPS 方案注册指定的策略。Setting this property registers the specified policy for the HTTP and HTTPS schemes. 此策略在以下情况下用于此请求:This policy is used for this request if:

没有为此请求指定 WebRequest.CachePolicy 属性。There is no WebRequest.CachePolicy property specified for this request.


计算机和应用程序配置文件不指定适用于用于创建此请求的统一资源标识符(URI)的缓存策略。The machine and application configuration files do not specify a cache policy that is applicable to the Uniform Resource Identifier (URI) used to create this request.

缓存策略确定是否可以从缓存中获取请求的资源,而不是将请求发送到资源主机计算机。The cache policy determines whether the requested resource can be taken from a cache instead of sending the request to the resource host computer.

如果资源的响应流已检索并读取到流的末尾,则仅将资源的副本添加到缓存中。A copy of a resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. 因此,对同一资源的另一请求可能会使用缓存的副本,具体取决于此请求的缓存策略级别。So another request for the same resource could use a cached copy, depending on the cache policy level for this request.


用于对网络资源进行无限制的访问。for unrestricted access to network resources. 关联的枚举: UnrestrictedAssociated enumeration: Unrestricted