@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