I recently created a post on how to set up a CDN for your WordPress blog, using Amazon CloudFront and W3 Total Cache. That post focused on setting up an Origin Pull with CloudFront. Another option available in W3 Total Cache is setting up a Origin Push for your CDN.
In this post we’ll examine setting up a CDN with Amazon CloudFront and W3 Total Cache Origin Push settings.
CloudFront Origin Pull vs. Origin Push
First off, let’s explain the difference between setting up a CloudFront CDN with Origin Pull vs. Origin Push.
My previous post focused on CloudFront using the Origin Pull option. In my opinion, this is by far the easiest option to choose.
An Origin Pull does exactly as it sounds. The CloudFront distribution will pull the required files directly from your Web Server. There is nothing special required of you to move files around, CloudFront will take care of all the heavy lifting for you.
An Origin Push is exactly the opposite. You need to push your files to the CloudFront distribution. Actually that’s not completely true. The CloudFront distribution will still get your files, but it does this via an S3 Bucket. You need to push the required files to your S3 Bucket in order for the distribution to retrieve.
Anytime a file is added or changed on your blog, using Origin Pull will result in the CloudFront distribution retrieving that file directly from your Web Server. With Origin Push, you have to physically move that added or changed file to your S3 Bucket, in order for the CloudFront distribution to retrieve that file.
I’m really not sure why anyone would go with Origin Push over Origin Pull. In my opinion, it’s far more involved and I don’t really understand the benefits. With that said, here’s a good article that seems to describe why you would want to use Origin Push vs. Origin Pull.
Amazon CloudFront And W3 Total Cache Origin Push
Instead of my writing a massive post on how to set up Amazon CloudFront and W3 Total Cache Origin Push, I thought it would be easier sharing the video I created.
You’ll want to check out my previous post on setting up a CDN with CloudFront. There are a number of things covered in that post that I don’t get into with this video, such as:
- Setting up an S3 Bucket
- Creating a User Group and User using Identity and Access Management
- Setting up your CloudFront distribution
Whether you are planning to use Origin Push or Origin Pull, the above three steps are identical.
Once you have an understanding of those basics, you’ll be ready to setup Amazon CloudFront and W3 Total Cache Origin Push.
Let’s take a look at setting up an Amazon CloudFront Origin Push distribution:
You can also view this video directly on YouTube.
Shawn Lehner says
You mentioned you weren’t sure why someone would want to use Origin Push over Pull. The main situation where Origin Push is important is when you have multiple Web Servers for a single site behind a load balancer. Pulling from the Web Server by Cloud Front assumes that the Web Server has your file available. In the situation I mentioned above, not all Web Servers would have the file so you can’t rely on hitting the Load Balancer and getting the asset. However, Origin Push allows you to push the uploaded files to S3 so that it does not rely on all Web Servers having the file.
Thanks for the feedback Shawn!
Nice set of articles on both origin pull and origin push. One thing I don’t quite understand is why you need an S3 bucket with origin pull. It really shouldn’t be necessary, since Cloudfront uses your webserver as the origin. However, I haven’t gone through the automated steps with W3 Total Cache, yet. It’s possible the plugin is setting up some rules / behaviors behind the scenes.
FYI, Amazon has posted a very detailed article showing a mixed setup using multiple origins for the same distribution: pushing static files to an S3 bucket and pulling dynamic data from your webserver / load balancer. I found it very interesting and informative:
Also, for anyone else in the same situation, I wasn’t aware that W3 Total Cache handled CDN use. I originally setup WP Offload S3 Lite and am now finding that I don’t need it.
Glad you liked them Jeff. For the life of me I can’t figure out why you need an S3 Bucket created for the Origin Pull. Couldn’t get it to work without this. There seems to be something going on there. If you happen to discover something different, please let us know. Also thanks for sharing those articles, I’ll have to take a look.
Fantastic set of articles. I’ve successfully set up the WordPress site to use a S3 Bucket combined with Cloudflare and CloudFront using the Push method.
However, our front end is an Angular Universal using the WordPress Rest Api. The W3 Cache doesn’t appear to work with the Rest Api, unless I’m missing something.