Steps To Perform Invalidation in AWS CloudFront

Step 1: Create an EC2 instance. Use the below script to install Apache on your ec2 instance. This script will also create an index.html in /var/www/html/ path.

#!/bin/bash
sudo yum update -y
sudo yum install httpd -y
echo "In this article I will perform invalidation in AWS CloudFront" >/var/www/html/index.html
sudo systemctl start httpd
sudo systemctl enable httpd

After successful creation of EC2 instance you can then access the Public IP of EC2 instance to see the website content .

Step 2 : Copy the DNS of EC2 instance .

Step 3 : Go to CloudFront and create a CloudFront distribution using EC2 instance as origin . First paste the copied DNS in the origin block . Then create a cache policy . Attach the cache policy to CloudFront distribution . At the end give the root object that is index.html .

Step 4 : Wait until the CloudFront distribution is deployed . After successful deployment access the website using CloudFront distribution URL .

Step 5 : Now make some changes in the website content . Connect EC2 instance and go inside the path /var/www/html/ . Edit the index.html .

sudo su
cd /var/www/html/
vi index.html

Step 6 : Now access the updated website through Public IP of EC2 instance .

Step 7 : Now try to access the website through CloudFront URL but you will see there are no updates in the website content .

Step 8 : Go to CloudFront distribution and select invalidations .

Step 9 : Create invalidation . Add /* to delete all the cache contents .

Step 10 : Wait for sometime until the CloudFront distribution is deployed successfully . Then access the CloudFront URL , now you can see the updated website .

AWS CloudFront Create-Invalidation

AWS CloudFront is a CDN service that accelerates content delivery globally. Invalidation is a key feature of AWS CloudFront which allows you to promptly remove outdated content from the edge locations. In this article, you will explore what is AWS CloudFront, how CloudFront works, and the significance of invalidation. I will also provide the steps to perform invalidation in AWS CloudFront manage your content effectively and ensure seamless user experiences.

Similar Reads

What is AWS CloudFront?

Suppose you have a website with awesome images, videos, and other content. Many people access the website. However, there is a certain problem many users of the website may face which is high latency. Due to high latency users will have a bad experience when accessing the website. To solve such a situation content delivery network (CDN) comes to the clutch. CDN is a network of interconnected servers(servers present in different edge locations ) that speeds up webpage loading. AWS CloudFront is an Amazon CDN service that delivers content, images, and videos with low latency and high transfer speed. AWS CloudFront can integrate with other AWS services to deliver content with high transfer speed and low latency....

What is Invalidation in AWS CloudFront?

Let’s say you have a website running on an EC2 instance and it is accessed through the CloudFront distribution URL. When any request comes first to CloudFront, basically it will store the website in the cache or edge location. After storing the website in the cache any further requests made in the future to access the website, then CloudFront will deliver the content from the cache....

Steps To Perform Invalidation in AWS CloudFront

Step 1: Create an EC2 instance. Use the below script to install Apache on your ec2 instance. This script will also create an index.html in /var/www/html/ path....

Conclusion

First we learned about the what is AWS CloudFront and how AWS CloudFront works . Then we have discussed about one of the important feature AWS CloudFront that is invalidation . We have also followed the steps to perform invalidation in AWS CloudFront . This step ensured that all the cache content will be deleted . Then finally accessed the updated website content....

AWS CloudFront Create-Invalidation – FAQs

Is It Possible Perform Partial Invalidation ?...