Share via


HttpCacheVaryByParams クラス

VaryByParams プロパティを設定するタイプ セーフな手段を提供します。

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public NotInheritable Class HttpCacheVaryByParams
'使用
Dim instance As HttpCacheVaryByParams
public sealed class HttpCacheVaryByParams
public ref class HttpCacheVaryByParams sealed
public final class HttpCacheVaryByParams
public final class HttpCacheVaryByParams
適用できません。

解説

VaryByParams プロパティは、リソースに対してキャッシュされている応答が複数ある場合に、ASP.NET で HTTP Get パラメータまたは Post パラメータのどちらを使用して応答を一意に識別するかを示します。これは、応答がヘッダーやパラメータなどのクライアント入力に依存している場合に便利です。

HttpCacheVaryByParams は HTTP キャッシュ コントロール ヘッダーと直接の関係はありませんが、クライアントまたはプロキシが指定したパラメータで識別できることを保証するのに役立ちます。VaryByParams の詳細については、W3C (World Wide Web Consortium) Web のサイトで『RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1』を参照してください。詳細については、第 14 項「Header Field Definitions」を参照してください。

使用例

HttpCacheVaryByParams オブジェクトに、HttpResponse に関連付けられている HttpCachePolicy オブジェクトからアクセスする方法を次のコード例に示します。

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(False)
Response.Cache.VaryByParams("Category") = True

If Response.Cache.VaryByParams("Category") Then
   '...
End If
 
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(false);
Response.Cache.VaryByParams["Category"] = true;

if (Response.Cache.VaryByParams["Category"])
{
   //...
}
get_Response().get_Cache().SetExpires(DateTime.get_Now().
    AddSeconds(60));
get_Response().get_Cache().SetCacheability(HttpCacheability.Public);
get_Response().get_Cache().SetValidUntilExpires(false);
get_Response().get_Cache().get_VaryByParams().
    set_Item("Category", true);

if (get_Response().get_Cache().get_VaryByParams().
    get_Item("Category")) {
    //...
}
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(false)
Response.Cache.VaryByParams("Category") = true

if(Response.Cache.VaryByParams("Category")){
   //...
}
 

.NET Framework のセキュリティ

継承階層

System.Object
  System.Web.HttpCacheVaryByParams

スレッド セーフ

この型の public static (Visual Basicでは共有) メンバはすべて,スレッド セーフです。インスタンス メンバの場合は,スレッド セーフであるとは限りません。

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

HttpCacheVaryByParams メンバ
System.Web 名前空間
HttpCachePolicy.VaryByParams プロパティ
BasePartialCachingControl
StaticPartialCachingControl
HttpCacheVaryByHeaders

その他の技術情報

ページの複数バージョンのキャッシュ