Skip to content

Instantly share code, notes, and snippets.

@cyberdelia
Created April 2, 2010 13:11
Show Gist options
  • Save cyberdelia/353112 to your computer and use it in GitHub Desktop.
Save cyberdelia/353112 to your computer and use it in GitHub Desktop.
Set cache-control headers for a s3 public bucket
#!/usr/bin/env python
# encoding: utf-8
from boto.s3.connection import S3Connection
AWS_ACCESS_KEY = '<aws access key>'
AWS_SECRET_KEY = '<aws secret key>'
AWS_BUCKET_NAME = '<aws bucket name>'
AWS_HEADERS = {
'Cache-Control':'max-age=31556926,public'
}
AWS_ACL = 'public-read'
conn = S3Connection(AWS_ACCESS_KEY, AWS_SECRET_KEY)
bucket = conn.get_bucket(AWS_BUCKET_NAME)
bucket.make_public()
for key in bucket.list():
print key.name
key.set_contents_from_string(None, headers=AWS_HEADERS, replace=False, policy=AWS_ACL)
@szepeviktor
Copy link

It hasn't set the cache control
wget -S http://tamasix4.s3.amazonaws.com/wp-content/themes/TidalForce/style.css

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