What is it?

My take

It’s a CDN for static and dynamic content. It replicates your content across AWS zones but also what they call edge locations which I just see as cached content closer to the end-user with the lowest latency it can grant you.

Do I use it currently?

Yes, I personally use it in production to front an S3 bucket we deploy a single-page-app into. This is pretty cheap to run but you need to know the gotchya's of using the CDN and Edge locations TTL (time to live or time it sticks around if the term isn’t familiar for you) to avoid situations where cached HTML pages are looking for assets that are no longer present because you’ve replaced them.

Source: AWS Documentations

When you request an asset via Cloudfront, if the edge location has a copy of that asset, that is what you get 🎉 but if not it will ‘miss’ and go to the S3 ‘origin’.

When you need to get rid of the cache’s e.g. you just updated content, then you need to ‘invalidate’ it (for a charge).

Use case

A bucket located in London is being used by a lot of users in Australia what can you do to improve performance.

One might have been S3 replication but a good idea might be to set up a distribution via Cloudfront so that cached versions of that content are found closer to those users.

Creating a ‘distribution’?

  1. Make sure your user has a CloudFront policy to let them use it, I’m lazy and just used CloudfrontFullAccess.
  2. Go to https://console.aws.amazon.com/cloudfront/
  3. Click on Create Distribution
  4. For now, everything can default except the Origin. In this example, I’m using my sandbox S3 bucket

5. Scroll down and press the Create Distribution button

The distribution will start deploying and it can take a while sometimes to propagate. Once it's done you’ll see something

Then you can pull assets from the bucket now using the Origin url https://d1zq4ei7l1j6ct.cloudfront.net. Accessing bucket objects for this will be going to the closes Edge Location for it rather than back to the origin.

Testing it?

Beyond the scope of this article but you could set up something like a bucket in one region e.g. London and then VPN to Sydney. Try curling the asset directly in the bucket and seeing what kind of download speed and latency you’re getting. Then do the same for the CloudFront one and see the difference.

Looking ahead

This was just a lighter touch on Cloudfront, there are actually quite a few areas you can go into. I will decide tomorrow if I want to continue being exhaustive or to move around a bit. I’ve got a list right now of a few things I’d like to cover off:

  • EC2’s
  • Load Balancers
  • Auth (IAM’s)
  • DNS (Route53)
  • Databases (RDS, DynamoDB)
  • VPC’s
  • SNS / SQS / API Gateways
  • + more

I’d like to finish getting through this before 2021 ideally, so I can take the associate exam. That being said, I’ve also got some other things I’m learning in more depth alongside this with a little cross over (Serverless Architecture using AWS Lambdas and a React frontend). I might write some stories about that as I go as well.




Fullish-stack engineer (codebykev.dev) and Lead front-end engineer @Cinch with 20 developing stuff for things with screens since the turn of the millenium.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Putting It All Together: The Real Win

Reflection on working with H/FOSS


Top 7 Replies by Programmers when their programs don’t work:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin Jones

Kevin Jones

Fullish-stack engineer (codebykev.dev) and Lead front-end engineer @Cinch with 20 developing stuff for things with screens since the turn of the millenium.

More from Medium

6 Easy GitHub Suggestions To Improve Your Branding


Use Cases and Tips for Contextual Content Variables (CCVAR) from ACS AEM Commons

4 Must-Have HR Tools for Remote Employee Engagement

Military Touchscreen Challenges | Shadowsense | Baanto