Skip to content

Instantly share code, notes, and snippets.

@wlrs
Created November 15, 2011 01:23
Show Gist options
  • Save wlrs/1365811 to your computer and use it in GitHub Desktop.
Save wlrs/1365811 to your computer and use it in GitHub Desktop.
Set far future cache control for existing files in an s3 bucket
require 'rubygems'
require 'aws/s3'
AWS::S3::Base.establish_connection!(
:access_key_id => '',
:secret_access_key => ''
)
bucket = AWS::S3::Bucket.find('my_bucket')
objects = bucket.objects
size = objects.size
objects.each_with_index do |file, index|
path = file.path
print "#{index + 1}/#{size} #{path} ... "
file.cache_control = 'max-age=315360000'
file.save({:access => :public_read})
puts "done."
end
@winzig
Copy link

winzig commented Aug 9, 2013

FYI, this appears to download each file locally, then upload it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment