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"])
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With