I have a master page which has a rather simple menu system. The menu items available are based on the logged on user. However, the database calls to determine this logic are over a second which is probably too long for my liking.
Is there a way to wrap the Menu into a UserControl but along with having a duration to refresh but obviously also the output cache should be on a per user basis?
I know the other solution is to cache the data for each user and then rebuild but I thought the more efficent place to start would be Page Output cache.
Please note also this application does not user Session state.
You can look at VaryByParam
method of Page Output Caching.
When your user logs in add a query string to your page something like page.aspx?uid=x123
then add the following to your page:
<%@ OutputCache Duration="10800" VaryByParam="uid" %>
This will make it per user cache.
Do remember:
Even if you put your user as a query string, still do the validation, that its the same user who logged in, to avoid users peeking into each other's view by simply changing the query string.