Few days ago I was facing an issue that the assets served from the S3 buckets are not as fast as I wanted them to be and then I heard about a solution from AWS that is Cloud Front.
So I am writing this blog so that you get to know that how easy is to integrate cloud front in your website.
Cloud front is a service provided by the AWS that provides a simple and cost effective way to improve the performance and reliability of your website.
How does cloud front works :
As you save your original versions of your files or assets on one or multiple location on servers. and when you create a cloud front distribution it creates references to the original content from different data centers of amazons which are called edge locations. So when a user requests a content you are serving the user gets the response from the nearest edge location in the best possible performance with reduced time delay.
Integrating Cloud front :
Integrating cloud front is so simple. You just need to follow these steps:
Go to amazon web console and select the service CloudFront.
Click create distribution.
Click on get started under web in select delivery method.
On the next page select the bucket for which you want to create distribution in ORIGIN DOMAIN NAME.
Now leave all the fields as it is and click Create Distribution at the bottom of the page.
Now a new screen appears where status tab shows In Progress and after Amazon cloud front creates distribution distribution it changes to deployed.
Amazon provides a domain for the content in domain name field something like this.
Now for serving your content from cloud front you just need to do is that replace your existing assets url that were directly being served from the s3 to the new domain name associated. example if the your current asset url is something like "http:://some-domain-url.amazonaws.com/asset-file-name" then you need to replace it with new domain as "http://d235fjidgdkajd.cloudfront.net/asset-file-name". It means you need to replace only domain name of the address.
So now your assets are ready for being served from aws cloud front.
Thanks for reading my blog. I hope it is helpful for you.