AWS Amazon CloudFront – How to enable cache for whole site

|
| By Webner

AWS Amazon CloudFront is a web service that speeds up serving static and dynamic web content like, .html, .css, .php, and image files and videos. It also integrates with other Amazon Web Services like S3, EC2, Elastic Load Balancer and Route 53. It also works seamlessly with any non-AWS origin server, which stores the original, definitive versions of your files.

Here I am providing steps about how to configure content distribution service with an existing ec2-server where site is hosted that we want to be on AWS edge locations :

1.  Open CloudFront service from AWS console panel.

2.  Click on Create Distribution :

1801

3.   Then from delivery method for your content click Get Started under web :

1802
4.  Now put the public dns of ec2-server in the Origin Domain Name field :
1803
1804

5.  Go with the default settings and hit Create Distribution button :
1805

 

Now you have to make changes in Route 53 configuration :

1. Open Route 53 from AWS console :
1806
2. On the Hosted Zones page, choose to create a domain like example.com :
1807
3. Then copy all the NS location something like mentioned below :
ns1.amazon.com
ns2.amazon.org
ns3.amazon.net
Ns4.amazon.co.uk

And point your domain to the above mentioned NS (Name Server) location, Settings will be in your Domain Hosted partner :
1808
4. Now click Record Sets option to create record set.

5. Choose Type A record from the list.

6. Select Yes from Alias Option.

7. Now put the Cloudfront URL in Alias Target which was generated while creating Distribution :

1809
8. Hit the Create button to save the record set.

Note: Generally it will propagate in 2 to 48 hrs

9. When distribution status shows Deployed, try to open your web url it will now show you content from cloudfront edge location which is near to your region.

Leave a Reply

Your email address will not be published. Required fields are marked *