Mike Gleason
Mike Gleason

Reputation: 1469

Providing administration on Actions/pages with [OutputCache] - in mvc3

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...

Upvotes: 1

Views: 347

Answers (2)

Mike Gleason
Mike Gleason

Reputation: 1469

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.

Upvotes: 1

danludwig
danludwig

Reputation: 47375

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.

Upvotes: 0

Related Questions