RenderAction and cache

1 view
Skip to first unread message

Matthieu GD

unread,
Nov 7, 2009, 12:43:10 PM11/7/09
to Spark View Engine Dev
Hello,

I would like to use RenderAction in my Master Layout to render some
information from a controller.

What I should do is :

- Create a controller with a method returning a View like
MyViewPartial.spark fron the ControllerName folder ?

In my master I will have a call like this : !
{Html.RenderAction<Controller>(c => c.Method())}

But if I want to cache the result, I will certainly hit this problem :
http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx

The solution from this blog post is for the WebForm view engine,
There's a way to use Spark to cache the partial result ?

Thanks

Matthieu

Louis DeJardin

unread,
Nov 7, 2009, 1:46:52 PM11/7/09
to spar...@googlegroups.com
First thing you might want to try could be putting <cache> around the call to renderaction? 

Matthieu GD

unread,
Nov 7, 2009, 2:11:30 PM11/7/09
to Spark View Engine Dev
thanks, I will try. There's some special requirements if I precompile
my views ?

Louis DeJardin

unread,
Nov 7, 2009, 2:16:12 PM11/7/09
to Spark View Engine Dev
Urr.... Nope don't think so... It'll be the same code that's just
wrapping the area with a cache hit test and repeats the original delta
if so. The asp.net cache is the default backing system.

Matthieu GD

unread,
Nov 7, 2009, 5:42:23 PM11/7/09
to Spark View Engine Dev
Thanks lou, it's working. Here is my code for other :

in my controller I render the view as partial :

return PartialView("Recent", model);

in my master i add the cache with a time to live :

<div id="LatestComments">
<cache key="MvcApplication.RECENTCOMMENTS"
expires="DateTime.UtcNow.AddMinutes(15)">
<% Html.RenderAction<CommentController>(c => c.Index()); %>
</cache>
</div>
Reply all
Reply to author
Forward
0 new messages