Topic: Action caching when action renderins a different action

New to caching - I'm using memcached with cache_fu plugin. I'd like to cache an action that's rendered in another action, but since the db calls are in the first action, I'm not getting the results I expect. Sample code below (this is existing code I'm trying to work around):

On index action, if a user isn't logged in, then the welcome action is rendered instead. A logged in user gets dynamic content. I would like to action cache the 'welcome' action and db calls for non-logged in user.

I tried putting '@latest = Products.recent_products(10)' in the 'welcome' action, but since I'm it's rendering a different action, that code won't get called.

So how could I separate this so I can action cache the welcome action for non-logged in user and keep it dynamic for logged in user?

Thanks...


def index
  unless logged_in?
    @latest = Products.recent_products(10)
    render :action => 'welcome' and return false
  end
  # other code for logged in user
end

def welcome
  # use this template if user not logged in
end

Re: Action caching when action renderins a different action

Found my answer - I was using a 'cacheable?" condition that wasn't quite correct...