HttpRequestCachePolicy Class
.NET Framework 3.0
Defines an application's caching requirements for resources obtained by using HttpWebRequest objects.
Namespace: System.Net.Cache
Assembly: System (in system.dll)
Assembly: System (in system.dll)
You can specify a default cache policy for your application by using the DefaultCachePolicy property or the application or machine configuration files. For more information, see requestCaching Element (Network Settings).
You can specify the cache policy for an individual request by using the CachePolicy property.
Caching for Web services is not supported.
The following code example creates a default cache policy for the application domain, and overrides it for a request.
// The following method demonstrates overriding the // caching policy for a request. public static WebResponse GetResponseNoCache(Uri uri) { // Set a default policy level for the "http:" and "https" schemes. HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default); HttpWebRequest.DefaultCachePolicy = policy; // Create the request. WebRequest request = WebRequest.Create(uri); // Define a cache policy for this request only. HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); request.CachePolicy = noCachePolicy; WebResponse response = request.GetResponse(); Console.WriteLine("IsFromCache? {0}", response.IsFromCache); return response; }
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: