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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Nichols <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Nichols <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Excellent. Just the information I was after. Thank you. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---