Topic: Caching action called by ajax

Hi,
I have a action dynamic_favorites in my Users controller. There is caches_action :dynamic_favorites too.

I call it by:
new Ajax.Updater('dynamic_nav', '/users/dynamic_favorites/'+id, {asynchronous:true, evalScripts:true});

But action is not cached. My question is - why?

If I call the action directly (localhost/users/dynamic_favorites/4) it is cached. But no by ajax request.

I want to cache some actions and load them to page by ajax (time consuming actions).

Thanks for replies.

Re: Caching action called by ajax

I am asking my self the exact same thing. Have you found any solution?

Re: Caching action called by ajax

bjerre wrote:

I am asking my self the exact same thing. Have you found any solution?

Yes. I do it by caches_page :dynamic_favorites

and expiring by sweeper:

def after_create(record)
    ActionController::Base::expire_page('/users/dynamic_favorites/'+record.user_id.to_s)
end

you have to set all path with "/" at the begin

Re: Caching action called by ajax

But "caches_page :dynamic_favorites" was what you originally did right? So why does it work now?

Re: Caching action called by ajax

bjerre wrote:

But "caches_page :dynamic_favorites" was what you originally did right? So why does it work now?

Not, originally I did it by caches_action and it didnt work. Now it is by caches_PAGE.