I have this action method:
[OutputCache(Duration = 2, Location = OutputCacheLocation.Any, VaryByHeader = "Accept-Charset")] public ActionResult Index() { return View(); }
And the generated answer:
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
Why does the Vary heading show an asterisk instead of Accept-Charset ?
OutputCacheAttribute affects the response, in fact, the Expires and Cache-Control:max-age=n headers depend on the Duration argument, and Cache-Control:public / private / no-cache depends on the Location .
I created a wrapper for OutputCacheAttribute to see what happens:
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(); } }
Headers do not appear in the break, so it is possible that OutputCacheAttribute does configure HttpContext.Current.Response.Cache .
I see filterContext.HttpContext.Response.Cache.VaryByHeaders.UserCharSet true , and for example filterContext.HttpContext.Response.Cache.VaryByHeaders.AcceptTypes false , but the Vary header always says * .
I am wondering if the only possible values ββare four, listed as filterContext.HttpContext.Response.Cache.VaryByHeaders properties, can it be?
Greetings.