System.Web.HttpCachePolicy.SetMaxAge Method

Sets the Cache-Control: max-age HTTP header based on the specified time span.

Syntax

public void SetMaxAge (TimeSpan date)

Parameters

date
a TimeSpan

Remarks

Max-age is the maximum absolute time a document is allowed to exist before being considered stale.

The HttpCachePolicy.SetMaxAge(TimeSpan) method does not use sliding expiration and will fail if the expiration date violates the principle of restrictiveness.

HttpCachePolicy.SetMaxAge(TimeSpan) is introduced in the .NET Framework version 3.5. For more information, see The .NET Framework 3.5 Architecture.

Note:

If the HttpCachePolicy.SetMaxAge(TimeSpan) method is called repeatedly, on the second and subsequent calls, the value of the maximum age can only be decreased.

Requirements

Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0