Created
April 2, 2010 13:11
-
-
Save cyberdelia/353112 to your computer and use it in GitHub Desktop.
Set cache-control headers for a s3 public bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It hasn't set the cache control
wget -S http://tamasix4.s3.amazonaws.com/wp-content/themes/TidalForce/style.css