私はこのアクションメソッドを持っています:
[OutputCache(Duration = 2,
Location = OutputCacheLocation.Any,
VaryByHeader = "Accept-Charset")]
public ActionResult Index()
{
return View();
}
そして、生成された応答は次のとおりです。
Cache-Control:public, max-age=2
Content-Length:5164
Content-Type:text/html; charset=utf-8
Date:Wed, 28 Sep 2011 16:30:33 GMT
Expires:Wed, 28 Sep 2011 16:30:35 GMT
Last-Modified:Wed, 28 Sep 2011 16:30:33 GMT
Server:Microsoft-IIS/7.5
Vary:*
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
X-Powered-By:ASP.NET
Varyヘッダーに代わりにアスタリスクが表示されるのはなぜAccept-Charsetですか?
OutputCacheAttribute応答に影響を与えますが、実際には、ヘッダーExpiresとCache-Control:max-age=nヘッダーはDuration引数に依存し、 Cache-Control:public//は引数に依存しprivateます。no-cacheLocation
OutputCacheAttribute何が起こっているかを確認するためのラッパーを作成しました。
public class CustomOutputCacheAttribute:OutputCacheAttribute
{
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
base.OnResultExecuted(filterContext);
Dictionary<String, String> headers = new Dictionary<string, string>();
foreach (var header in filterContext.HttpContext.Response.Headers.AllKeys)
headers.Add(header, filterContext.HttpContext.Response.Headers[header]);
Debugger.Break();
}
}
ヘッダーは区切りに表示されていないので、おそらくOutputCacheAttributeconfigureが何をするのでしょうかHttpContext.Current.Response.Cache。
どのようfilterContext.HttpContext.Response.Cache.VaryByHeaders.UserCharSetにtrueであるか、たとえばfalsefilterContext.HttpContext.Response.Cache.VaryByHeaders.AcceptTypesであるかはわかりますが、ヘッダーには常に*と表示されます。Vary
可能な値は、のプロパティとしてリストされている4つの値だけfilterContext.HttpContext.Response.Cache.VaryByHeadersでしょうか?
乾杯。