Search code examples
wordpressamazon-web-servicescachingamazon-s3amazon-cloudfront

After visiting my site I have to refresh for new content. I use cloudfront


I have a WordPress website on AWS with 2 EC2 instances behind a load balancer. Then I have CloudFront directing to that load balancer and S3 handles my images.

We publish articles daily. When I visit the site, I then need need to reload the page to see new articles.

I set all of this up. However, I do not know CloudFront well enough to know how to diagnose or solve the issue. I'm only assuming it is CloudFront as no other caching tools are in use.

If it is CloudFront, what might be the issue? If not, then how should I proceed to solve this?


Solution

  • You can solve this by setting the TTL from the origin and just telling CloudFront to use the origin's cache headers.

    Alternatively, you can do this just in CloudFront directly by

    • setting the behavior of index.html to be 0 TTL (leave all other settings the same) and
    • the default behavior for everything else *, and set the TTL to be whatever you prefer.

    Path Patterns for Cache Behaviours is a very useful article