# AWS CloudFront Deep Dive.

## **Introduction**

AWS CloudFront is a content delivery network that allows for global reaching and instant, efficient delivery of your content to your users. CloudFront caches its content in globally located network points, giving you speed advantages as well as security for your deliveries. In this blog post, we will cover the key features, benefits, use cases, and implementations of AWS CloudFront.

### **How does CloudFront Works?**

**Step 1:** The client accesses a website and requests to download a file (like image file).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735478655437/49b2b07c-1641-4a0b-a99a-e5288dea7280.jpeg align="center")

**Step 2:** Now, the DNS routes the client request to the nearest edge location through CloudFront to serve the user request.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735478717854/0d686be8-f625-4dcc-ab97-d69dbb3b110a.jpeg align="center")

**Step 3:** At edge location, CloudFront looks for its requested cache file. Once the file is found, CloudFront sends the file to the user.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735478781146/0e61c388-c0eb-4465-a68c-68c6246caa06.jpeg align="center")

**Step 4:** But, if the file is not found then CloudFront compares the requirements with the specifications and shares it with the respective server. 

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735478819028/1db4defe-310d-4d2a-8a6a-6d4fea3a09a1.jpeg align="center")

**Step 5 :** The web server responds to the request by sending the files back to the CloudFront edge location.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735478866663/65d167e8-701d-4b9f-a196-b60224ea7b5d.jpeg align="center")

### **Benefits of Using CloudFront:**

1. Improved User Experience: CloudFront makes the even user experience possible, minimizing load times, which serve to retain visitors, hence reducing bounce rates for your global news website.
    
2. Cost Effective: CloudFront simply charges you for the data transfer rate. It follows a pay-as-you-go pricing model.
    
3. Scalable: With CloudFront, the scaling is automatic, meaning you can simply deploy and forget it because it can automatically handle traffic spikes.
    
4. Security: With an integrated security service, CloudFront assures secure content delivery for you and protects it from potential risks and attacks.
    

### **Real life Applications of CloudFront:**

1. Website Content Delivery: CloudFront reduces the load on your origin servers and accelerates content delivery to users by caching static assets such as HTML, CSS, and images.
    
2. Streaming Media: This service works for any demand and allows the streaming of live media to your worldwide audience with the least amount of buffering and latency.
    
3. API Acceleration: Using CloudFront at the front end of your APIs will very much minimize latency and optimize your application delivery.
    
4. Software Distribution: With its global presence, few can distribute software updates like CloudFront, ensuring fast and reliable delivery.
    

### Implementation of AWS CloudFront Using AWS Management Console (UI)

Step 1: Create a S3 Bucket:

1. **Sign in to the AWS Management Console**:
    
    * Go to the AWS Management Console.
        
2. **Navigate to S3**:
    
    * In the AWS Management Console, go to **Services** &gt; **S3**.
        
3. **Create a New Bucket**:
    
    * Click **Create bucket**.
        
    * Enter a unique bucket name (e.g, my-website-bucket).
        
    * Choose the region (e.g, us-east-1).
        
    * Click **Create bucket**.
        

Step 2: Create a CloudFront Distribution

1. **Navigate to CloudFront**:
    
    * In the AWS Management Console, go to **Services** &gt; **CloudFront**.
        
2. **Create a New Distribution**:
    
    * Click **Create Distribution**.
        
3. **Set Origin Settings**:
    
    * Origin domain: Enter the S3 bucket's URL (e.g., my-website-bucket.s3.amazonaws.com).
        
    * Origin ID: Example mys3origin.
        
    * Leave other settings as default or customize as needed.
        
4. **Set Default Cache Behavior**:
    
    * Allowed HTTP Methods: Select GET,HEAD.
        
    * Viewer Protocol Policy: Select Redirect HTTP to HTTPS.
        
5. **Set Distribution Settings**:
    
    * Price Class: Choose one based on your budget and geographical needs.
        
    * Click **Create Distribution**.
        
6. **Wait for Deployment**:
    
    * It may take some time for the distribution to deploy and become active.
        

#### Step 3: Validate Configuration

1. **Access the Distribution**:
    
    * Once deployed, you can use the CloudFront domain name to access your content.
        

### **Conclusion**

AWS CloudFront is a multi-purpose and powerful Content Delivery Network (CDN) solution. It has several useful features for content delivery enhancement. Interestingly, it can be extremely easy to set up CloudFront with both Terraform and AWS Management console implementations. Leveraging the power of AWS CloudFront, your global news website can deliver content quickly, securely, and efficiently to users from all over the world.
