ASP.NETキャッシュOutputCacheとResponse.CacheのC#バックグラウンド設定
3269 ワード
、ASPX
, aspx <%@ OutputCache Duration="60" VaryByParam="none" %>
, ASP.NET 、 , 。
。 1 1 、 100 。
、outpuCache
Duration: ,
VaryByParam: ,
VaryByParam=none , ;
VaryByParam="*" , VaryByParam="*", “*” 。
VaryByParam="id" ?id=2、?id=3 , , VaryByParam="id"
DiskCacheable="true|false"
注意:Buffer=true;次の設定が有効になります.ページのデフォルトはtrueです.
三、以下はコード例の@OutputCache命令と等価なプログラミングコードである.
<%@ 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);
<%@ OutputCache Duration="60" Location="Downstream" VaryByParam="None" %>
プログラミングの方法:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetNoServerCaching();
<%@ 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);
<%@ OutputCache duration="60" varybyparam="City" %>
プログラミングの方法:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.VaryByParams["City"] = true;
:HttpResponse.RemoveOutputCacheItem("/index.aspx");
: