Search code examples
amazon-cloudfrontbrowser-cache

How to cache images on AWS CloudFront


When I run a pagespeed analysis on a clients website page I see that there is no Cache policy setup. I however have two cache policies setup in CloudFront but it seems to not have any affect. How do I enable a cache policy for images using CloudFront?

enter image description here

The AWS cache policies:

enter image description here


Solution

  • According to the answer below the caching referred to is the Edge caching and not browser caching. How to enable browser cache in AWS cloudfront

    Do the following:

    1. Click on your Distribution
    2. Click on Behaviours
    3. Select your Default behaviour and Edit
    4. Scroll down to Response headers
    5. Click on Create response header policy
    6. Name it Cache-Control or whatever you want
    7. Under Custom Headers click Add header
    8. Name = cache-control
    9. Value = public, max-age=63072000
    10. Click on Create
    11. Ensure your Cache-Control custom policy selected like the image below.

    enter image description here