There are two ways for Cloudfront to work.
1. You upload all your wordpress static files (you wp-content and wp-includes folders) onto Amazon S3, then tell Cloudfront to get your files from Amazon S3 as it needs them.
2. You tell Cloudfront to get the files directly from your site as it needs them. This second way is called ‘Origin Pull’.
The advantage of 1 is that if you ever change your wordpress host, your entire wp-content folder is stored off-site at Amazon S3, so you don’t need to even copy your wp-content folder to your new wordpress installation. The new S3 wp-content folder becomes your wp-content folder – you can even load images directly to S3 and then insert them into your wordpress posts.
The advantage of 2 is that it’s easier and cheaper, and you don’t need to upload the files to Amazon each time you make a new post.
Cloudfront is a CDN designed for global content delivery. However, recent improvements allow it to act not only as a CDN, but also as a cache similar(ish) to Varnish.
People originally had to use Cloudfront by uploading their media to Amazon S3. Cloudfront then served those static assets from the S3 bucket. This means that within a coded application, developers needed to upload assets to S3 and then point URLs within their HTML (and perhaps in user-generated content) to a Cloudfront URL.
.. For instance, if you have a file
example.com/css/styes.css, your Cloudfront URL
example.com/css/styes.cssand then serve a cached version of that stylesheet for future visitors.
Within your own HTML, of course, you set the URL of
styles.cssto be your Cloudfront URL
Further suppose that the web server from which you’re serving the image is in Seattle, Washington, USA, and that a user in Austin, Texas, USA requests the image. The traceroute list below (courtesy of www.WatchMouse.com) shows one way that this request could be routed.
In this example, the request was routed 10 times within the United States before the image was retrieved, which is not an unusually large number of hops. If your user were in Europe, the request would be routed through even more networks to reach your server in Seattle. The number of networks and the distance that the request and the image must travel have a significant impact on the performance, reliability, and availability of the image.