Working Of CloudFront
Let’s say you have a website deployed on an EC2 instance. When a user requests the website the request goes to Cloudfront first. Here’s how the process flows :
- Step 1: First Cloudfront checks if it already has the website content in its cache. If it does, then it sends website content directly to the user. If not it proceeds to Step 2.
- Step 2: CloudFront fetches the website content and stores a copy in its cache for future requests. Then sends the website content to the user.
Next time if someone requests the same website then Cloudfront will deliver the content from the cache making it more efficient and fast.
Customize responses in AWS Cloudfront
Imagine you have a website with good content like images, videos, and documents. Various users visit the website. However, users who live far away from the server will face latency in accessing the website content. High latency can hamper user experience. To solve this problem CDN comes into the picture.
CDN stands for content delivery network. It is a network of interconnected servers which speeds up the webpage loading. Website content is stored on the CDN servers which is geographically closer to the user and respond to user requests more quickly. Cloudfront is AWS’s own CDN service. CloudFront integrates with other AWS services and delivers content, images, and videos with low latency and high transfer speed.