Skip to content

Instantly share code, notes, and snippets.

@amui
Created April 1, 2015 19:37
Show Gist options
  • Save amui/bf083bcb79e33519a8a7 to your computer and use it in GitHub Desktop.
Save amui/bf083bcb79e33519a8a7 to your computer and use it in GitHub Desktop.
Set cache-control max-age for objects in S3 bucket
from boto.s3.connection import S3Connection
# make sure api creds set, KEY/SECRET are just placeholders
connection = S3Connection(KEY, SECRET)
bucket = connection.get_bucket("just.a.test.bucket.really")
keys = bucket.get_all_keys()
for key in keys:
key.set_metadata('Cache-Control','max-age=43200')
key.copy(
key.bucket.name,
key.name,
key.metadata,
preserve_acl=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment