Location-Based Cache Policies
A location-based cache policy defines the freshness of valid cached entries based on where the requested resource can be taken from. A cached resource is valid if using it does not does not violate server-specified revalidation requirements. A location-based cache policy is created programmatically by using a RequestCachePolicy or HttpRequestCachePolicy class constructor. The type of location-based policy is passed to the constructor using a RequestCacheLevel or HttpRequestCacheLevel enumeration value. For code examples that create location-based cache policies, see How to: Set a Location-Based Cache Policy for an Application. The following sections explain each type of location-based cache policy for Hypertext Transfer Protocol (http and https) resources.
If a valid requested resource is in the local cache, the cached resource is used. When this cache policy level is specified, a WebException exception is thrown if the item is not in the local cache.
If a valid requested resource is in the local cache or an intermediate cache on the local area network, the cached resource is used. Otherwise, a WebException exception is thrown. In the HTTP caching protocol, this is achieved using the only-if-cached cache control directive.
A requested resource is never used from any cache and is never placed in any cache. If a requested resource is present in the local cache, it is removed. This policy level indicates to intermediate caches that they should also remove the resource. In the HTTP caching protocol, this is achieved using the no-store cache control directive.
A requested resource can be used if it is obtained from the server or found in a cache other than the local cache. Before the request can be satisfied by an intermediate cache, that cache must revalidate its cached entry with the server. In the HTTP caching protocol, this is achieved using the max-age = 0 cache control directive and the no-cache Pragma header.
Compares the copy of the resource in the cache with the copy on the server. If the copy on the server is newer, it is used to satisfy the request and replaces the copy in the cache. If the copy in the cache is the same as the server copy, the cached copy is used. In the HTTP caching protocol, this is achieved using a conditional request.