WebResponse.IsFromCache 属性


获取一个 Boolean 值,该值指示此响应是否为从缓存中获取的。Gets a Boolean value that indicates whether this response was obtained from the cache.

 virtual property bool IsFromCache { bool get(); };
public virtual bool IsFromCache { get; }
member this.IsFromCache : bool
Public Overridable ReadOnly Property IsFromCache As Boolean


如果此响应来自缓存,则为 true;否则为 falsetrue if the response was taken from the cache; otherwise, false.


缓存中当前缓存策略和请求的资源的状态确定是否可以从缓存中检索响应。The current cache policy and the presence of the requested resource in the cache determine whether a response can be retrieved from the cache. 使用缓存的响应通常会提高应用程序的性能,但存在缓存中的响应与服务器上的响应不匹配的风险。Using cached responses usually improves application performance, but there is a risk that the response in the cache does not match the response on the server. 使用 CachePolicy 属性设置,并使用 RequestCachePolicy 类来枚举当前缓存策略。Use the CachePolicy property to set and the RequestCachePolicy class to enumerate the current caching policy.

请注意,获取此属性可能会引发 ObjectDisposedExceptionNote that getting this property can throw ObjectDisposedException.