Chapter 7 – Amazon Cloud Front
Chapter 7 of this blog post series will be all about Amazon’s front-end caching service, Amazon CloudFront.
CDN = Content Delivery Network…
…It is a system of distributed servers (network) that deliver webpages and other web content to a user based on the geographic locations of the user, the origin of the webpage and a content delivery server.
Key CloudFront Terminology:
- Edge Location – This is the location where content will be cached. This is separate to an AWS Region or Availability Zone
- Origin – This is the origin of all the files that the CDN will distribute. This can be either an S3 Bucket, an EC2 instance, an Elastic Load Balancer or Route53
- Distribution – This is the name that is given to the name of the CDN which consists of a collection of Edge Locations.
First user does not experience speed increases, however the rest of the users using that Edge Location will receive much faster response since the content is cached there.CloudFront can be used to deliver your entire website, including dynamic, static, streaming, and interactive content using a global network of edge locations. Requests for your content are automatically routed to the nearest edge location, so conent is delivered with the best possible performance.
CloudFront is optimized to work with other Amazon Web Services, like Amazon S3 (Simple Storage Service), Amazon EC2 (Elastic Compute Cloud), Amazon Elastic Load Balancing, and Amazon Route 53. Amazon CloudFront also works seamlessly with any non-AWS origin server, which stores the original and definitive versions of your files.
- Types of Distribution:
- Web Distribution – Typically for website RTMP – Used for Media Streaming
- Edge Location
- Edge Locations are not just READ only, you can write to them too
- Objects are cached for the life of the TTL (Time-to-Live) – Objects will automatically expire
- You are charged for manually clearing the cache
Exam topic Restrict Viewer Access.You can use WAF – Web Application Firewall – Layer 7 protectionYou can have multiple origins – ie multiple ec2 or s3 buckets be the origin and even an external website like on-premises or Azure 🙂
Restrictions: Enable Geo-Restrictions – Restriction types are whitelist / blacklist
Invalidations: Invalidating objects removes them from the CloudFront edge caches. A faster and less expensive method is to use versioned object or directory names. Costs $ – will stop an item or object from being cached.