amazon – How to Cache All WordPress Assets via CloudFront


I am using Amazon Cloudfront to cache my WordPress site, with the following steps:

  1. My site is
  2. I use Duplicator to create a package for my site.
  3. I launch a EC2 instance in Amazon.
  4. I add the following A record in’s DNS zone: -> IP of the EC2 instance.

  1. I install a Let’s Encrypt certificate for on the EC2 instance so that I can access the website via
  2. I start Duplicator installer in and set the new website URL to:

  1. After completing the Duplicator installation, I can visit my website via
  2. Now I create a Cloudfront distribution, and set the origin to
  3. Then I can access the distribution via a URL like this

But, via Chrome DevTools, I find only the webpage is retrieved from, all the assets on the page, such as the image, css and javascript, seems to using a absolute URL of, which is not cached by Cloudfront.

So, for such a issue, what will be a good solution?

What I can figure out is:

  1. Change all the absolute URLs in the theme to relative URLs, but that will be time-consuming?
  2. Change the WordPress Address (URL) and Site Address (URL) of the website to This seems not change everything, I am just searching to see if there are more to be replaced. But In such a case, I will never be able to visit via
  3. Use WP Rocket to set CDN and change all static assets to CDN URL, like, this may also not change everything. I am studying to see if that it works.
alancc 3 months 2021-09-17T20:32:30-05:00 0 Answers 0 views 0

Leave an answer