Production Caching 'send_data' Nginx, Rails

I’m having an issue when trying to send a dynamically generated pdf with nginx & rails using the ‘send_data’ method. I’ve made some changes to the pdf generator, but no matter what I do the production application isn’t picking up the changes… I’m guessing that somewhere along the line the originally rendered pdf is getting cached? By nginx or rack maybe?

Here’s the controller method:

def show
  @proof_list = ProofList.new(@client)

  respond_to do |format|
    format.html
    format.pdf do
      pdf = ProofListReport.new(@proof_list)
      send_data pdf.render, filename: "Proof List #{Date.today}.pdf",
                            type: "application/pdf",
                            disposition: "inline"
    end
  end
end

Saw a note in the API docs indicating that caching might be an issue with the send_data/send_file method, but no real direction on how to address it: send_file (ActionController::DataStreaming) - APIdock

I tried adding the following to the controller show method:

response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"

And then replacing those lines with this:

expires_now()

But nothing has helped. Is there something in nginx or rack that could be causing this?

Argh, nevermind… I had renamed the original file I was replacing (but forgot the rename the class definition) and so the production app was picking up the class from the old file.

I just renamed the old versions class, and things worked perfectly.

Strange that development was picking up the class from the new file while production was picking up the class from the old file.