HttpRequestCachePolicy Constructor (DateTime)

 

Initializes a new instance of the HttpRequestCachePolicy class using the specified cache synchronization date.

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

public HttpRequestCachePolicy(
	DateTime cacheSyncDate
)

Parameters

cacheSyncDate
Type: System.DateTime

A DateTime object that specifies the time when resources stored in the cache must be revalidated.

The cache synchronization date allows you to specify an absolute date when cached contents must be revalidated. If the cache entry was last revalidated prior to the cache synchronization date, revalidation with the server occurs. If the cache entry was revalidated after the cache synchronization date and there are no server revalidation requirements that make the cached entry invalid, the entry from the cache is used. If the cache synchronization date is set to a future date, the entry is revalidated every time it is requested, until the cache synchronization date passes.

This constructor initializes the Level property to Default. The CacheSyncDate property is initialized to cacheSyncDate.

The following code example demonstrates creating a cache policy based on a cache synchronization date.

public static HttpRequestCachePolicy CreateLastSyncPolicy(DateTime when)
{
    HttpRequestCachePolicy policy = 
       new HttpRequestCachePolicy(when);

    Console.WriteLine("When: {0}", when);
    Console.WriteLine(policy.CacheSyncDate.ToString());
    return policy; 
}

.NET Framework
Available since 2.0
Return to top
Show: