KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an asp.net mvc 3 project and I have a home controller. I have tagged my Index action with this attribute: [OutputCache(Location = System.Web.UI.OutputCacheLocation.Any, Duration = 120, VaryByParam = "*", VaryByCustom = "user")] public ActionResult Index() { return View(); } The vary by custom with user is handled in Global.asax.cs to check the user cookie value so that caching changes based on whether the user is logged in or not and what user they are. When I go to this page on my web server, I get these headers in the response: Cache-Control public, max-age=120 Content-Type text/html; charset=utf-8 Content-Encoding gzip Expires Sun, 20 Mar 2011 21:50:09 GMT Last-Modified Sun, 20 Mar 2011 21:48:09 GMT Vary Accept-Encoding Date Sun, 20 Mar 2011 21:48:09 GMT Content-Length 3105 Right off the bat, the Vary - Accept-Encoding value looks wrong, shouldn't it have sent a Vary - * instead? I am rendering the User.Identity.Name property to this view as well and I am noticing that even when I log out it will still render the user name, until the 120 seconds expires. public override string GetVaryByCustomString(HttpContext context, string custom) { if (custom.Equals("user", StringComparison.OrdinalIgnoreCase)) { HttpCookie cookie = context.Request.Cookies["user"]; if (cookie != null) { return cookie.Value; } } return base.GetVaryByCustomString(context, custom); } Been playing with this for several hours, and am completely stuck, hopefully someone has an idea...
Tags (comma-separated)
Save Edits
Cancel