DEV Community

Revathi Joshi for AWS Community Builders

Posted on

Use Amazon CloudFront for dynamic Websites - 3

Please read my 2 previous articles Use Amazon CloudFront for dynamic Websites -1 and Use Amazon CloudFront for dynamic Websites -2

In this article, I am going to show you how to create the CloudFront Distribution and test it.

Let’s get started!

Please visit my GitHub Repository for S3 articles on various topics being updated on constant basis.

5. Create the CloudFront Distribution.

  • CloudFront is a content delivery network (CDN) that caches and serves content from multiple edge locations worldwide.
  • When you create a CloudFront distribution with the Application Load Balancer as the origin, it accelerates the delivery of the dynamic PHP webpage, reducing latency and improving user experience.
1.

Image description

2. Origin Domain Name: Select the Load balancer my-LB that you created

Image description

  • take defaults
3.

Note: enable the query string forwarding because our server can accept the query string parameter ID

Image description

Note: The TTL option will be in disabled for dynamic contents by setting it to 0.

4.

Image description

  • Take all defaults

  • Click on the Create distribution

5. Status column shows Deploying, and then shows Last Modified Date for your distribution. Wait for the deployment to complete.

Note: Wait for This process will take around 4-5 minutes.

Image description

6. Test the distribution.

1. test the CloudFront distribution to verify that it is correctly serving content from the EC2 instances through the Application Load Balancer.
  • Copy the CloudFront distribution Domain name and paste it in the browser and hit [enter].

Image description

2. refresh the page and see the instance ID change, and the time will keep incrementing.

Image description

3. Pass the query string parameter to CloudFront domain.
http://<domain name>/?id=CloudFront

http://dua7m5h1l3jyg.cloudfront.net/?id=CloudFront
Enter fullscreen mode Exit fullscreen mode

Image description

Cleanup

  • Delete Security Group and EC2 instance
  • Remove index.php file from S3 bucket
  • Delete Target Group and Load Balancer
  • Delete Cloudfront Distribution

What we have done so far

  • We have successfully created and tested the CloudFront Distribution with the Application Load Balancer as the origin.
  • It show how it accelerates the delivery of the dynamic PHP webpage, reducing latency and improving user experience.

Top comments (0)