1

We've come up with 3 options for providing administration buttons on Actions/pages with caching and would like to know if there are other options or performance/memory/usability issues to be aware of:

  1. Donut-hole caching - http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx
  2. VaryByCustom - http://visitmix.com/writings/using-varybycustom-with-outputcache-in-asp-net-mvc-to-support-caching-for-logged-in-users
  3. Create separate Admin Actions/pages

EDIT: Is there a way to "Overload" Actions? i.e. It would be idea if there was a way to call an Action which has an [OutputCache] attribute for non-admin users and an Action with no [OutputCache] attribute for admin users.

Background: We have a very simple blog and wanted to allow Administrative users to Edit/Delete posts and to approve comments. So, we added buttons that are rendered only for administrative uses using the solution shown in asp.net MVC3 razor: display actionlink based on user role - ".If(User.IsInRole("Administrators"))".

Then, we added [OutputCache(Duration = 30)] to that Action and found that everone would see either the Admin version or the plainer - depending on who happened to be the first to request the page after the cache timed out. Duh...

Community
  • 1
  • 1
Mike Gleason
  • 1,479
  • 14
  • 17
  • Have you tried rendering the admin link as a child action, then applying the outputcache to the child action only (with VaryByCustom on the user's role)? – danludwig Dec 09 '11 at 19:13
  • Not yet - but it's an option. The main thing we're interested in caching is the non-admin portion. So I suspect we'd create separate child actions for the admin and non-admin sections then use VaryByCustom to apply [OutputCache] to the non-admin portion. – Mike Gleason Dec 09 '11 at 19:29
  • Just FYI, we deploy our app to Azure, and their output cache provider is very immature. We have completely disabled output caching on our MVC app for this very reason. So, if you are ever considering using Azure, I wouldn't spend too much time on this concern. – danludwig Dec 09 '11 at 19:34

2 Answers2

1

We ended up choosing option "3.Create separate Admin Actions/pages".

This allows us the option of creating a separate website/subdomain for administration and simplifies the caching structure - we likely won't do any caching on the Admin pages.

Mike Gleason
  • 1,479
  • 14
  • 17
0

This may only be a partial answer to your question edit:

AFAIK, you can only create 2 overloads of the same action method: one of them must be a HttpPost, and the other must be a HttpGet, and they (of course) must have different params to compile.

danludwig
  • 46,965
  • 25
  • 159
  • 237