Namespace: System.Net

RequestCachePolicy Class

Provides a base class for implementing custom cache policies for HTTP requests.

Inheritance

  • System.Object
  • System.Net.Cache.RequestCachePolicy

Remarks

The RequestCachePolicy class is an abstract base class that defines the contract for cache policies used by the .NET Framework's HTTP caching mechanisms. Concrete implementations of this class can be used to control how HTTP responses are cached, retrieved, and invalidated.

When you make an HTTP request using classes like HttpWebRequest, you can associate a cache policy with that request. This policy determines whether and how the response is stored in the cache. The default cache policy can be configured at the application level or overridden for individual requests.

Key aspects controlled by a cache policy include:

  • Whether caching is enabled for a given request.
  • The maximum age of cached entries.
  • The conditions under which cached entries can be revalidated with the server.
  • Specific directives for handling cached content (e.g., always cache, never cache).

The System.Net.Cache namespace provides several built-in cache policy implementations, such as HttpRequestCachePolicy and HttpResponseCachePolicy, which cover common caching scenarios.

Methods

This is an abstract class and does not directly expose public methods for instantiation or general use. You would typically work with derived classes that implement its behavior.

Properties

Derived classes of RequestCachePolicy may expose specific properties to configure caching behavior. Common properties often relate to cache age, revalidation, and expiration.

Requirements

Namespace:System.Net.Cache
Assembly:System (in System.dll)

See Also