How to use browser caching with Amazon S3?

4thSpace picture 4thSpace · Mar 19, 2013 · Viewed 21k times · Source

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?

Answer

Flavio Wuensche picture Flavio Wuensche · May 4, 2017

Via Amazon Management Console, select your file (or folder).

enter image description here


Go to the Properties tab and click on Metadata.

enter image description here


Finally, add Cache-Control to its header and save.

enter image description here