HttpCachePolicy.SetMaxAge(TimeSpan) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the Cache-Control: max-age
HTTP header based on the specified time span.
public:
void SetMaxAge(TimeSpan delta);
public void SetMaxAge (TimeSpan delta);
member this.SetMaxAge : TimeSpan -> unit
Public Sub SetMaxAge (delta As TimeSpan)
Parameters
- delta
- TimeSpan
The time span used to set the Cache
- Control: max-age
header.
Exceptions
delta
is less than 0 or greater than one year.
Examples
The following code example demonstrates how to set the Cache-Control: max-age
header to 0 hours, 30 minutes, and 0 seconds.
TimeSpan ts = new TimeSpan(0,30,0);
Response.Cache.SetMaxAge(ts);
Dim ts As New TimeSpan(0,30,0)
Response.Cache.SetMaxAge(ts)
Remarks
Max-age
is the maximum absolute time a document is allowed to exist before being considered stale.
The SetMaxAge method does not use sliding expiration and will fail if the expiration date violates the principle of restrictiveness.
SetMaxAge is introduced in the .NET Framework version 3.5. For more information, see Versions and Dependencies.
Note
If the SetMaxAge method is called repeatedly, on the second and subsequent calls, the value of the maximum age can only be decreased.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기