Skip to main content

Three Use Cases Where You Should Use Amazon CloudFront

Amazon CloudFront is likely not the most common and known service in the AWS family. Nevertheless, it proves to be a very interesting alternative to S3 or other products alike when you aim not to the storage in itself, rather to delivering content for your appliance. Indeed, CloudFront is a content delivery web service with “low latency, high data transfer speeds, and no commitments”. Despite that, I see that CloudFront is often poorly used or unused at all. So, to make clear what it is thought for and how to take advantage of it, let’s see 3 typical use cases where you should use Amazon CloudFront.

Three use cases where you should use Amazon CloudFront

Replace S3 with CloudFront when your userbase is geographically distributed

S3 is typically used to store and deliver data for your appliance. Unfortunately, this is a poor choice when the userbase is geographically distributed and you can’t focus your storage on a particular area of the world to achieve the lowest possible latency. On the other hand, CloudFront has a global network of so-called “edge locations”, which are data centers spread around the world, all replicating the content you would like to deliver to your user. Every time a resource is asked for by end users, the request is automatically routed to the nearest edge location, in order to achieve high-performance delivery of the content. In addition to that, you can even set different domain aliases for your CloudFront distribution, that is, having cdn1.mydomain.com, cdn2.mydomain.com, and so on, all pointing to the same CloudFront distribution. This allows parallel downloads and improves, even more, the performance of your appliance.

Harness the Origin Servers feature to cache dynamically generated content

When Cloud Front was launched, it was a feeder of content stored on S3 only. You put your objects on Amazon S3, CloudFront takes and caches them on the edge locations, then delivers them from there. This was quite a strong limitation for certain applications, but later on, Amazon introduced a feature called “Origin Servers” that quite changed the game.

Adding a Custom Origin Server allows CloudFront to feed content from anywhere, even from your on-premises web server, or a machine from another cloud provider. The great thing behind that is that you can deliver even automatically generated content via CloudFront, and use CloudFront to replace a custom caching solution. CloudFront allows you to tune quite finely its behavior, especially thanks to HTTP headers like Cache-Control, who control how long CloudFront should cache a given resource. Another nice feature is that CloudFront supports Etag headers.

Do you know what Etag is? They are a sort of a hash, or a digest, of the given resource. Modern browser uses them to save bandwidth. When a browser requests something that is available in browser’s cache, it will send a special If-Match header with the ETag of the resource from the cache. CloudFront will compare this ETag with ETag from his cache and will respond with HTTP 304 Not Modified without sending the resource again. Just add Etag’s to your content on CloudFront and this behavior will be automatically triggered.

CloudFront caching on steroids: Whole-Site Delivery

If we can deliver even dynamically generated content, why not taking full advantage of it and move to a Whole-Site Delivery approach? In the typical usage pattern, CloudFront act as a CDN for static content only, typically hosted either on S3 or on your Custom Origin server. Nevertheless, we have just seen how you can use it to cache dynamic content from your origin server. So, what blocks from using CloudFront as a CDN for your whole website? The key idea here is to use CloudFront as a proxy for both S3 (where your static assets are stored) and your EC2 instance, or your on-premises Custom Origin server (where dynamic content is generated).

If this seems a bite off more than you can chew, fear not: a lot of websites already use an approach like this, with a significant improvement of their performance. The idea that user-personalized pages can’t be delivered via CDNs is simply a myth. Truth is that network and path optimizations allow CloudFront to speed up dynamic content without losing a bit in customization. Setting up this architecture isn’t difficult at all, you will probably need some time to perfectly tune it, but your profits in term of performance, better scalability, improved availability, and reduced costs will go way beyond that.

Avatar

Written by

Andrea Colangelo

Software Engineer with a solid focus on QA and an extensive experience in ICT. Above all, Andrea has a very strong interest in Free and Open Source Software, and he is a Debian and Ubuntu Developer since years. Non-tech interests include: Rugby, Jazz music and Cooking.

Related Posts

Sam Ghardashem
Sam Ghardashem
— May 15, 2019

Aviatrix Integration of a NextGen Firewall in AWS Transit Gateway

Learn how Aviatrix’s intelligent orchestration and control eliminates unwanted tradeoffs encountered when deploying Palo Alto Networks VM-Series Firewalls with AWS Transit Gateway.Deploying any next generation firewall in a public cloud environment is challenging, not because of the f...

Read more
  • AWS
Joe Nemer
Joe Nemer
— May 3, 2019

AWS Config Best Practices for Compliance

Use AWS Config the Right Way for Successful ComplianceIt’s well-known that AWS Config is a powerful service for monitoring all changes across your resources. As AWS Config has constantly evolved and improved over the years, it has transformed into a true powerhouse for monitoring your...

Read more
  • AWS
  • Compliance
Avatar
Francesca Vigliani
— April 30, 2019

Cloud Academy is Coming to the AWS Summits in Atlanta, London, and Chicago

Cloud Academy is a proud sponsor of the 2019 AWS Summits in Atlanta, London, and Chicago. We hope you plan to attend these free events that bring the cloud computing community together to connect, collaborate, and learn about AWS. These events are all about learning. You can learn how t...

Read more
  • AWS
  • AWS Summits
Paul Hortop
Paul Hortop
— April 2, 2019

How to Monitor Your AWS Infrastructure

The AWS cloud platform has made it easier than ever to be flexible, efficient, and cost-effective. However, monitoring your AWS infrastructure is the key to getting all of these benefits. Realizing these benefits requires that you follow AWS best practices which constantly change as AWS...

Read more
  • AWS
  • Monitoring
Joe Nemer
Joe Nemer
— April 1, 2019

AWS EC2 Instance Types Explained

Amazon Web Services’ resource offerings are constantly changing, and staying on top of their evolution can be a challenge. Elastic Cloud Compute (EC2) instances are one of their core resource offerings, and they form the backbone of most cloud deployments. EC2 instances provide you with...

Read more
  • AWS
  • EC2
Avatar
Nitheesh Poojary
— March 26, 2019

How DNS Works – the Domain Name System (Part One)

Before migrating domains to Amazon's Route53, we should first make sure we properly understand how DNS worksWhile we'll get to AWS's Route53 Domain Name System (DNS) service in the second part of this series, I thought it would be helpful to first make sure that we properly understand...

Read more
  • AWS
Avatar
Stuart Scott
— March 14, 2019

Multiple AWS Account Management using AWS Organizations

As businesses expand their footprint on AWS and utilize more services to build and deploy their applications, it becomes apparent that multiple AWS accounts are required to manage the environment and infrastructure.  A multi-account strategy is beneficial for a number of reasons as ...

Read more
  • AWS
  • Identity Access Management
Avatar
Sanket Dangi
— February 11, 2019

WaitCondition Controls the Pace of AWS CloudFormation Templates

AWS's WaitCondition can be used with CloudFormation templates to ensure required resources are running.As you may already be aware, AWS CloudFormation is used for infrastructure automation by allowing you to write JSON templates to automatically install, configure, and bootstrap your ...

Read more
  • AWS
  • CloudFormation
Badrinath Venkatachari
Badrinath Venkatachari
— February 1, 2019

10 Common AWS Mistakes & How to Avoid Them

Massive migration to the public cloud is changing architecture patterns, operating principles, and governance models. That means new approaches are vital to get a handle on soaring cloud spend. Because the cloud’s short-term billing cycles call for financial discipline, you must empower...

Read more
  • AWS
  • Operations
Avatar
Andrew Larkin
— January 24, 2019

The 9 AWS Certifications: Which is Right for You and Your Team?

As companies increasingly shift workloads to the public cloud, cloud computing has moved from a nice-to-have to a core competency in the enterprise. This shift requires a new set of skills to design, deploy, and manage applications in cloud computing.As the market leader and most ma...

Read more
  • AWS
  • AWS Certifications
Avatar
Andrew Larkin
— January 15, 2019

2018 Was a Big Year for Content at Cloud Academy

As Head of Content at Cloud Academy I work closely with our customers and my domain leads to prioritize quarterly content plans that will achieve the best outcomes for our customers.We started 2018 with two content objectives: To show customer teams how to use Cloud Services to solv...

Read more
  • AWS
  • Azure
  • Cloud Computing
  • Google Cloud Platform
Avatar
Jeremy Cook
— November 29, 2018

Amazon Elastic Inference – GPU Acceleration for Faster Inferencing

“Add GPU acceleration to any Amazon EC2 instance for faster inference at much lower cost (up to 75% savings)”So you’ve just kicked off the training phase of your multilayered deep neural network. The training phase is leveraging Amazon EC2 P3 instances to keep the training time to a...

Read more
  • AWS
  • Elastic Inference
  • re:Invent 2018