クライアントから送信された、キャッシュを無効にする HTTP Cache-Control ヘッダーを ASP.NET キャッシュで無視するかどうかを指定します。
Public Sub SetValidUntilExpires( _
ByVal validUntilExpires As Boolean _)
[C#]
public void SetValidUntilExpires(boolvalidUntilExpires);
[C++]
public: void SetValidUntilExpires(boolvalidUntilExpires);
[JScript]
public function SetValidUntilExpires(
validUntilExpires : Boolean);
パラメータ
- validUntilExpires
キャッシュが Cache-Control 無効化ヘッダーを無視する場合は true 。それ以外の場合は false 。
解説
高レベルの <%@ OutputCache ...%> ページ ディレクティブが使用されると、SetValidUntilExpires は自動的に true に設定されます。
このメソッドが用意されている理由は、ページ ビューの更新時に HTTP キャッシュ無効化ヘッダーを Web サーバーに送信し、ページをキャッシュから消去するブラウザがあるためです。 SetValidUntilExpires を true に設定すると、ASP.NET はキャッシュ無効化ヘッダーを無視し、ページは有効期限が切れるまでキャッシュ内に残ります。
使用例
' The following example demonstrates the SetValidUntilExpires method of the
' HttpCachePolicy class. The SetValidUntilExpires method is set to true so that
' the ASP.NET cache ignores the HTTP Cache-Control headers and the page remains
' in the cache until it expires.
Sub Page_Load(Sender As Object, e As EventArgs)
' Set the expiration time for the page.
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
' Set the VaryByHeaders attribute with the value Accept-Language to true.
Response.Cache.VaryByHeaders("Accept-Language") = True
' ASP.NET ignores cache invalidation headers and the page remains in
' the cache until it expires.
Response.Cache.SetValidUntilExpires(True)
Response.Write("The SetValidUntilExpires method is set to true and the ASP.NET cache will " _
"& ignore the Cache-Control headers sent by the client that invalidate the cache.")
End Sub 'Page_Load
[C#]
// The following example demonstrates the SetValidUntilExpires method of the
// HttpCachePolicy class. The SetValidUntilExpires method is set to true so
// that the ASP.NET cache ignores the HTTP Cache-Control headers and the page
// remains in the cache until it expires.
void Page_Load(object Sender, EventArgs e)
{
// Set the expiration time for the page.
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
// Set the VaryByHeaders attribute with the value Accept-Language to true.
Response.Cache.VaryByHeaders["Accept-Language"] = true;
// ASP.NET ignores cache invalidation headers and the page remains in
// the cache until it expires.
Response.Cache.SetValidUntilExpires(true);
Response.Write("The SetValidUntilExpires method is set to true and ASP.NET cache should " +
"ignore the Cache-Control headers sent by the client that invalidate the cache.");
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ