2

I have a heavy page that is cached. This is okay for anonymous users. They all see the same page.

The problem is for logged in users. They should have minor parts of the page re-rendered on every request (like personal notes on content in the page, etc.) But still all the rest of the page should be cached (it does tons of SQL and calcuations when rendered).

As a workaround I put placeholders in page templates (like #var1#, #var2#,..). Then I make controller method to render View into string, where I do string.Replace #var1# and other into real values.

Any cleaner way to do such kind of partial "non-caching"?

4
  • If you're on MVC1, this might be useful: haacked.com/archive/2008/11/05/… Commented Oct 13, 2010 at 13:31
  • @Nik - According to the comments, that was updated for ASP.NET MVC 2 although it might be a bit buggy. Commented Oct 13, 2010 at 14:23
  • Thanks @Rob, look forward to non buggy implementation in v3! Commented Oct 13, 2010 at 20:11
  • 1
    you might get some milage out of serving the personalised bits by ajax on page load... Commented Oct 13, 2010 at 20:12

2 Answers 2

2

This is called donut caching.

The ASP.Net MVC framework doesn't currently support it, but it's planned for version 3.

Sign up to request clarification or add additional context in comments.

Comments

1

To start things off, it might make sense to go through the page and see if there is anything about it that you can do to streamline or reduce the weight. Depending upon how bad things are, investing some time here might pay off in the long run.

That said, in regards to trying to server the content to anonymous as well as logged in users, one option is to have two versions of the page: one for anonymous users and one for logged in users. This may not be the best approach though as it means that you now have two versions of the same page to maintain.

Given the lack of support doughnut caching mentioned by SLaks what I would likely do is try and cache the results of the calculations that are being done for the page (e.g. if you are querying a database for a table of data, cache a DataTable that you can check for before running the operation) and seeing what that does for the performance. It may not be the most elegant solution in the world, but it may solve the problems that you are having.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.