views:

53

answers:

1

I have a rails controller which must return a .csv file and I'd like this page to use cache. The cache works fine when I use a .xml format (it returns 304 http status), but when the format is csv, it always returns 200 http status.

here is my controller code:

  def index
    @machines = Machine.all
    respond_to do |wants|
      wants.xml { render :xml => @machines.to_xml }
      wants.csv
    end
  end

I've tried to put

  caches_page :index 

but it doesn't work.

A: 

The Action Cache Plugin will probably solve your problem.

Fix a bug in the original Rails code where responses other than '200 OK' are cached (since the headers aren't cached in the original, all the clients would get is an empty '200 OK' response from subsequent requests)

Diego Dias