Alex Rivera | Logout

Asp.net MVC 2 caching

Asked 2010-11-04T00:45:36.023
9

I'm currently developing a web site using asp.net mvc 2 in c#. I have never used the caching feature in MVC and would like to apply it to the user profile page. The content on this page rarely changes and the only part that needs to be in realtime is the list of recent posts by the user. (I use linq-to-sql to load data from the database)

I need some suggestions on what caching technique I should use and how to implement it?

Update: Xandy's solution below almost works, except I cannot pass in data. How would I rewrite this using the ? Html.RenderPartial("UserPosts", ViewData["UserPosts"])

Edit
Report

1 Answer

5

Phil Hack's fragment caching tricks no longer work in MVC2.

At StackOverflow we build html fragments as text and cache them using HttpRuntime.Cache and more.

answered 2010-11-04T08:21:29.750

Your Answer