Reputation: 44352
I get the following on gtmetrix.com:
Leverage browser caching
E (55)
52%
Server High
What does this mean?
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
http://mysite.s3.amazonaws.com/profile.png (expiration not specified)
http://mysite.s3.amazonaws.com/circle.player.css (expiration not specified)
http://mysite.s3.amazonaws.com/main.js (expiration not specified)
http://mysite.s3.amazonaws.com/not.the.skin.css (expiration not specified)
http://cdn-images.mailchimp.com/embedcode/slim-321711.css (expiration not specified)
I'm guessing the mailchimp files can't be modified. But how do I specify a browser cache for Amazon S3 Cloudfront files?
Upvotes: 19
Views: 23623
Reputation: 10386
Upvotes: 29
Reputation: 3722
You can specify header parameter with the s3cmd! while uploading files to s3.
eg :
s3cmd sync LOCAL_DIRECTORY s3://BUCKET[/PREFIX] --add-header=Cache-Control:max-age=3153600
Upvotes: 12
Reputation: 19573
When you store files to s3. You can set custom headers which will be send to the client. In this case, you can set an Expires header for your files.
Cloudfront works a little bit differently as it depends on your origin.
Upvotes: 8