Last Updated: February 25, 2016
·
907
· priteshjain

Set Meta Data for Public Paperclip Images

Always set the cache control header for images that are going to be publicly served to allow taking advantage of browser caching.

has_attached_file :image,
:styles => { :large => "300x", :thumb => "100x", :small => "30x" },
 :storage => :s3,
 :s3_credentials => "config/s3.yml",
 :s3_permissions => :public_read,
 :s3_headers => { 'Cache-Control' => 'max-age=315576000', 'Expires' => 10.years.from_now.httpdate },