Stop browser caching content

I have a small application that serves documents (typically PDF and
word). I’m using the file_column plug-in to update and manage the
documents. I’m serving the documents via Mongrel (this is a small
intranet application).

I have one main problem: users’ browsers are caching the documents, and
therefore new revisions of documents are not being downloaded by
everyone. I want to send an HTTP header Cache-Control statement limiting
the life of the documents to tens of minutes. Can I do this within my
Rails application?

If not, I’ll serve the documents via another server where I can set the
cache life at the folder level. However, it would be easier to manage
the system if the setting could be made within the Rails app.

If you’re serving the document from an action, you can add any header
you want by putting it in the headers[] hash:

class MyController < ActionController::Base
def file
headers[‘Cache-Control’] = ‘no-cache’
headers[‘Pragma’] = ‘no-cache’
# send file
end
end

On Apr 26, 6:04 pm, Rob N. [email protected]

Eden Li wrote:

If you’re serving the document from an action, you can add any header
you want by putting it in the headers[] hash:

class MyController < ActionController::Base
def file
headers[‘Cache-Control’] = ‘no-cache’
headers[‘Pragma’] = ‘no-cache’
# send file
end
end

On Apr 26, 6:04 pm, Rob N. [email protected]

Excellent. Just the information I was after. Thank you.