I am attempting to cache sections of a navigation menu according to different criteria.
For example, news and articles need to be refreshed on a duration basis, whereas login and profile stuff should be cached on a per user basis.
I'm considering 2 options - would anyone be kind enough to enlighten me about the pros / cons of each? And if possible suggest a better approach to take!
Option 1.
Simply cache all required html as strings in the Data Cache. Check for user differences manually when required.
I (perhaps incorrectly) imagine that this would be the most work to implement, but also the most efficient way of caching the different sections.
Option 2.
Have a NavigationController with different child action for each section of the menu. (We can apply a different outputCacheProfile on each child action as required.)
But this would require us to call a separate RenderAction for each section of the navigation menu. And I'm worried about this because of a comment on one of Phil Haack's blog posts:
[Render Action] is very similar to making another request since we need to run through routing to make sure we have the appropriate route data and context to call the action method. So each call to RenderAction is going to add up.
Full post here: http://haacked.com/archive/2009/11/18/aspnetmvc2-render-action.aspx