Caching only certain formats (xml) of an action

I’ve got a controller method that I’d like to cache … the problem is I
only want to cache the XML output of a method. (This is for a number of
reasons, including the fact that the feed of this action gets hit fairly
often, but the html result does no and also contains other,
user-specific info in the layout.)

In other words, I’m wondering how to do the following:


class MyController < ApplicationContorller

caches_action :index, :only_format => :xml

def index

@items = Item.find( :all )
respond_to |format| do
  format.html # This should not be action cached
  format.xml # This should be action cached
end

end

end


Thanks!

I suspect you’ll want to go beyond the pre-wired caching and use
something like memcache where you’ll have a lot more control over what
gets cached.

On Jan 28, 4:52 pm, Lance D. [email protected]

AndyV wrote:

I suspect you’ll want to go beyond the pre-wired caching and use
something like memcache where you’ll have a lot more control over what
gets cached.

On Jan 28, 4:52 pm, Lance D. [email protected]

Thanks for the reply … but what effect would the fragment storage
mechanism have on this functionality? AFAIK, file fragment storage has
just as many options for namespace tinkering etc that memcache does.