1

So, I have this website that is hosted in Amazon S3/CF and when I run any Performance analysis tool I get the following recommendation to set browser caching in some files: Leverage Browser Caching

So, I set in (most of the files) the: --cache-control "max-age=7776000, public" meta-tag as you can see here for example in animate.css:

curl -I https://counsellor.life/assets/css/animate.css % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 71569 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/1.1 200 OK Content-Type: text/css Content-Length: 71569 Connection: keep-alive Date: Fri, 19 May 2017 22:28:53 GMT Cache-Control: max-age=7776000, public Last-Modified: Fri, 19 May 2017 02:07:53 GMT ETag: "8bab56c3164c346a680ad414e6f1d7aa" Server: AmazonS3 Vary: Accept-Encoding X-Cache: Miss from cloudfront Via: 1.1 56908f89e8d17ba579c0607313114955.cloudfront.net (CloudFront)

CloudFront Configuration under Behavior:

CloudFront Caching Config

However I still getting the suggestion in those tools. Am I missing something?

  • Do a CloudFront invalidation for all objects *. Wait for it to complete, and run the test again. – Michael - sqlbot May 20 '17 at 3:32
  • technically you have added an HTTP header, not a meta tag. Images can't have meta tags. – Stephen Ostermiller May 20 '17 at 10:06
  • I did the invalidation already, issue persists. – RBenito May 21 '17 at 6:31
  • Did the tools ever pick up on your cache control, or are they still reporting problems? I usually use Expires headers, so it is possible that the max-age isn't recognized. However, it does appear to be valid and should take precedence over Expires: stackoverflow.com/questions/7549177/… – Stephen Ostermiller Aug 9 '17 at 9:02
  • @StephenOstermiller after some DAYS and at least 5 more invalidations it worked. I didn't investigate properly, so I have no clue why it happened. Its working now. – RBenito Aug 11 '17 at 18:31