クライアントとプロキシのキャッシュを無効にする
<%@ OutputCache Location="None" VaryByParam="None" %>
or
Response.Cache.SetCacheability(HttpCacheability.NoCache);
期間を指定して出力キャッシュを格納する
宣言によるアプローチ :
<%@ OutputCache Duration="60" VaryByParam="None" %>
プログラムによるアプローチ :
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
要求元のブラウザ クライアントに出力キャッシュを格納する
宣言によるアプローチ :
<%@ OutputCache Duration="60" Location="Client" VaryByParam="None" %>
プログラムによるアプローチ :
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Private);
HTTP 1.1 キャッシュに対応した任意のデバイス (プロキシ サーバーや要求送信元のクライアントなど) に出力キャッシュを格納する
宣言によるアプローチ :
<%@ OutputCache Duration="60" Location="Downstream" VaryByParam="None" %>
プログラムによるアプローチ :
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetNoServerCaching();
Web サーバーに出力キャッシュを格納する
宣言によるアプローチ :
<%@ OutputCache Duration="60" Location="Server" VaryByParam="None" %>
プログラムによるアプローチ :
TimeSpan freshness = new TimeSpan(0,0,0,60);
DateTime now = DateTime.Now;
Response.Cache.SetExpires(now.Add(freshness));
Response.Cache.SetMaxAge(freshness);
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetValidUntilExpires(true);
受信した各 HTTP 要求の City の値に応じて出力をキャッシュする
宣言によるアプローチ :
<%@ OutputCache duration="60" varybyparam="City" %>
プログラムによるアプローチ :
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.VaryByParams["City"] = true;
HttpCachePolicy クラスは、@ OutputCache ディレクティブの VaryByCustom 属性、VaryByHeader 属性、および VaryByParam 属性に対して、VaryByHeaders プロパティ、VaryByParams プロパティ、および SetVaryByCustom メソッドを提供します。
没有评论:
发表评论