diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-08 15:26:40 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-08 15:26:40 +0000 |
commit | 2dbabde7f40d6a58ef8df9f4e32b0f9a4ad43041 (patch) | |
tree | b9e76069c762f3c04117a64d6dd65a245d82e175 /app/controllers | |
parent | e74d4ecf5fa73690c91188a70425cc2d4640ecd9 (diff) | |
download | redmine-2dbabde7f40d6a58ef8df9f4e32b0f9a4ad43041.tar.gz redmine-2dbabde7f40d6a58ef8df9f4e32b0f9a4ad43041.zip |
Adds Etags on attachments.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9963 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/attachments_controller.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 4ef929896..edae9b0cc 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -52,19 +52,22 @@ class AttachmentsController < ApplicationController @attachment.increment_download end - # images are sent inline - send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => (@attachment.image? ? 'inline' : 'attachment') - + if stale?(:etag => @attachment.digest) + # images are sent inline + send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), + :type => detect_content_type(@attachment), + :disposition => (@attachment.image? ? 'inline' : 'attachment') + end end def thumbnail if @attachment.thumbnailable? && Setting.thumbnails_enabled? && thumbnail = @attachment.thumbnail - send_file thumbnail, - :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'inline' + if stale?(:etag => thumbnail) + send_file thumbnail, + :filename => filename_for_content_disposition(@attachment.filename), + :type => detect_content_type(@attachment), + :disposition => 'inline' + end else # No thumbnail for the attachment or thumbnail could not be created render :nothing => true, :status => 404 |