In this post i will explain what Amazon CloudFront CDN is and how to use it with magento.
Whether you just launched a new magento store or are maintaining an existing one, sooner or later you will take a look at possible ways to improve the performance of your magento store.
What is Amazon CloudFront?
If you have customers from Asia which requests your site in the US they get routed to the nearest edge location, so the content is delivered with the best possible performance.
Why should i use a CDN with Magento?
Easy Integration: The integration takes about 15 – 45 minutes, depending on your knowledge
Performance Booster: It’s really fast to use a edge locations around the world to deliver your static content.
Amazon CloudFront caches copies of your static content close to viewers, lowering latency when the download your static files.
It’s good way to offload your static files, all requests are handled by the amazon servers which decreases your server load.
Cost-Effective: Pay only for what you use. You only pay for the content that you deliver through the network.
Visit http://aws.amazon.com/cloudfront/pricing/ to get more information about pricing.
Reliable: Amazon CloudFront is built using a highly reliable infrastructure.
Step1: Configure Amazon CloudFront
1. Access CloudFront from the Amazon Web Services Management Console here: http://console.aws.amazon.com/cloudfront/home
2. Create a pull zone contribution by clicking “Create Contribution”.
Afterwards you should see a wizard in a dialog.
Ensure that the delivery method is set to “Download”.
3. Enter your Origin Domain Name and Origin Id
4. Configure the default behavior how CloudFront communicates with your origin
5. Enter distribution Details
Alternate Domain Names (CNAMEs): This field is not required. If you want use your own domain name (for example assets.mgt-commerce.com) instead of the Cloudfront domain name (e.g. d1256.cloudfront.net) for the URLs for your files.
6. When you are satisfied with the configuration, select “Create Distribution”. CloudFront will now generates then a domain for you to use. In our example it generates:
You can use this domain to deliver static content or your configured CNAMEs (e.g assets.mgt-commerce.com).
Before proceeding, you must wait for your CDN to propagate worldwide to the CloudFront servers.
This usually takes about 10 minutes and the status of your distribution will change from “In Progress” to “Deployed” in the CloudFront dashboard:
If you use your own CNAMEs please make sure to enter the domain in your domain management dashboard.
Step 2: Configure Magento
The integration is really easy and takes about 3 minutes.
Go to Magento Backend -> System -> Configuration -> Web -> Unsecure
Go to Magento Backend -> System -> Configuration -> Web -> Secure
What about updating the files when they change?
That’s a really good question. The files will expire from the network based on the expiration date (Cache control) when they were retrieved from the server.
How can i flush a single image or path?
I use the “Cloudfront Purge Tool” to purge files from Amazon Cloudfront.
It’s a little Chrome Extension.
This extension can be downloaded here: https://chrome.google.com/webstore/detail/gadbenpggeagjgnameagcpjnjdlckkpb
If you are familiar with the Amazon Api, you can write a little magento extension which purges the files automatically.