views:

264

answers:

1

Most of the web applications have pages that are "almost static" in the sense they change really very rarely their content, but when it changes this should be seen immediately on the page.

So if you have some OutputCache attribute that permits to cache forever on your PageShow method, the cache should be invalidated immediately by a call to the PageUpdate method.

Sometimes the data of the page is almost identical but a small part (like the username). Here I have the possibility to render the whole page calling different render partials or just move the cache part outside the controller to reduce the most expensive calls in the db for getting the data (ie: cache on the service-repository layer).

Is there a pattern to do both types of caching effectively on asp.net mvc?

+1  A: 

What you've suggested is a common scenario - especially with user names.

What this is called is donut caching and is a very kewl feature.

Here's a helpful StackOverflow question on the same topic .. which bounces you to this blog post (probably the most helpful link on this topic with regards to ASP.NET MVC).


A quick google search for this comes up with a number of helpful pages.

HTH!

Pure.Krome