views:

45

answers:

3

i have read a few different things, it sounds like output cache will not cache a different copy of results for each user. so if user A has 3 menus and user B only has access to 1 of them, then caching the view result would show all 3?

how can i cache things for each user so that it's not shared?

thanks!

A: 

One solution is to pass a parameter with the number of menus. Then configure outputcache to cache by all parameters except this one.

Also you can configure output cache to cache only on the client, not on the server It might be useful depending of your scenario.

despart
A: 

You can always cache user specific information on the asp.net session.

Mike
+1  A: 

Use VaryByCustom and redefine HttpApplication.GetVaryByCustomString:

public virtual string GetVaryByCustomString(
    HttpContext context,
    string custom
)
{
    //Return a value unique per user
    //Change depending on the authentication of your site (f.e. make use of Session)
    return context.User.Identity.Name;
}

http://msdn.microsoft.com/en-us/library/system.web.httpapplication.getvarybycustomstring.aspx http://asp.net-tutorials.com/caching/more-output-cache/

gustavogb