In my model, which is using paperclip. I have added this line of code but still its not working
has_attached_file :attachment, {
:styles => {
:medium => ["654x5000000>", :jpg],
:small => ["260x50000000>", :jpg],
:thumb => ["75x75#", :jpg],
:facebook_meta_tag =>["200x200#", :jpg]
},
:convert_options => {
:medium => "-quality 80 -interlace Plane",
:small => "-quality 80 -interlace Plane",
:thumb => "-quality 80 -interlace Plane",
:facebook_meta_tag => "-quality 80 -interlace Plane"
},
:s3_headers => { 'Cache-Control' => 'max-age=315576000', 'Expires' => 10.years.from_now.httpdate }
}.merge(PAPERCLIP_STORAGE_OPTIONS)
PS: I tested it on GTmetrix.com and as per their stats, expiry headers are not there in amazon images.
To expand on James' answer for others unsure about how to reprocess your old attachments, there are two ways to do so:
1) Reprocess all attachments via rake (optionally per CLASS)
rake paperclip:refresh CLASS=User
2) Reprocess specific attachments (e.g. via migration)
User.where("attachment IS NOT NULL").find_each do |user|
user.attachment.reprocess!
end
For more info, see https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation#generatingregenerating-your-thumbnails
It looks like you didn't re-process/upload your old attachments and that's why their headers haven't changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With