HttpCachePolicy.SetProxyMaxAge(TimeSpan) 方法

定義

根據指定的時段設定 Cache-Control: s-maxage HTTP 標頭。Sets the Cache-Control: s-maxage HTTP header based on the specified time span.

public:
 void SetProxyMaxAge(TimeSpan delta);
public void SetProxyMaxAge (TimeSpan delta);
member this.SetProxyMaxAge : TimeSpan -> unit
Public Sub SetProxyMaxAge (delta As TimeSpan)

參數

delta
TimeSpan

用以設定 Cache-Control: s-maxage 標頭的時段。The time span used to set the Cache-Control: s-maxage header.

例外狀況

delta 小於 0。delta is less than 0.

範例

下列程式碼範例示範如何將 Cache-Control: s-maxage 標頭設定為0小時、30分鐘和0秒。The following code example demonstrates how to set the Cache-Control: s-maxage header to 0 hours, 30 minutes, and 0 seconds.

TimeSpan ts = new TimeSpan(0,30,0);
 Response.Cache.SetProxyMaxAge(ts);

Dim ts As New TimeSpan(0,30,0)
 Response.Cache.SetProxyMaxAge(ts)
 

備註

SetProxyMaxAge如果到期日違反 restrictiveness 原則,方法不會使用滑動期限,而且將會失敗。The SetProxyMaxAge method does not use sliding expiration and will fail if the expiration date violates the principle of restrictiveness.

SetProxyMaxAge 在 .NET Framework 版本3.5 中引進。SetProxyMaxAge is introduced in the .NET Framework version 3.5. 如需詳細資訊,請參閱版本和相依性For more information, see Versions and Dependencies.

適用於