Okay, works fine now! I slightly changed the way I overwrote the
ActionCacheFilter.

On 30 Nov., 22:58, nico <nico.rits...@googlemail.com> wrote:
> Okay, I debugged a bit more and found out what the problem is
> (at least when locally in development environment). Inside the action
> cache content_for_layout
> is called to get the content to be cached if layout is set to false.
> This causes
> my ajax requests to be not cached because content_for_layout returns
> nil as
> I don't render the layout with ajax calls, only a partial. So I do
> need to set
> layout to true for ajax calls. However I can't do that the way I tried
> to, as
> the layout param doesn't accept a Proc. So I overwrote part of the
> ActionCacheFilter class
> to test the layout for a call method and call it if present. That
> works great locally!
> However, in production on Heroku with Memcached it still won't work
> properly.
> Ajax calls are not cached.
>
> On 30 Nov., 16:30, nico <nico.rits...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > Hi there,
>
> > I'm using Action Caching with Rails 2.3.8 on Heroku with Memcached
> > (via Dalli Gem).
>
> > Without the layout parameter Action Caching works fine. However, as
> > soon as I add layout => false I get problems: Normal non-ajax requests
> > are cached fine, without the layout, as expected. But ajax requests
> > are not properly cached: I get cache misses all the time. Then, when I
> > log in to my app neither normal, nor ajax requests are cached at all.
>
> > I also tried to set :layout => Proc.new { |c| c.request.xhr? }
> > When I do that ajax and normal requests are properly cached (no matter
> > if logged out or logged in)
> > but normal requests also cache the layout. Seems odd to me as normal
> > requests should have :layout => false.
> > I'm trying to debug this for hours now, but I haven't got a clue
> > what's going on so far. What especially confuses me
> > is that the logged in state of my app apparently has an influence on
> > the caching behaviour.
>
> > Here is my full caching call (for the case of layout => false):
>
> > [code]caches_action :index, :layout => false,
> >                       :cache_path => Proc.new { |c|
> > c.params.clone.delete_if { |k,v| ['authenticity_token'].include?
> > (k) }.merge(:xhr => c.request.xhr? ? 't' : 'f') }[/code]
>
> > I'd greatly appreciate any help on this!
>
> > Nico

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to