How to Use Amazon CloudFront Free CDN to Boost Site Speed

Amazon CloudFront free tierAWS CDN setupCloudFront SSL certificateCDN cache configurationAWS free usage limits
Published·Modified·

Amazon CloudFront is included in the free tier of Amazon Web Services. It is a fast content delivery network (CDN) service designed to securely and efficiently distribute data, videos, applications, and APIs to users globally via AWS's global edge node network. By caching content and optimizing transmission, it significantly improves website and application loading speeds while providing data encryption and network protection to ensure secure content delivery.

54b1e43c7322bb83.png

Amazon CloudFront Free Tier Inclusions

As part of the AWS free usage tier, you can start using Amazon CloudFront for free. The free tier includes the following:

  • 1TB of data transfer per month to the internet
  • 10,000,000 HTTP or HTTPS requests per month
  • 2,000,000 CloudFront function invocations per month
  • 2,000,000 CloudFront KeyValueStore reads per month
  • Free SSL certificate
  • Unlimited access to all features

This free allowance is sufficient for most general websites.

Reference: Amazon CloudFront Pricing

Register an AWS Account

Before using Amazon CloudFront, you need to register for an AWS account. You will need:

  • A frequently used email address
  • A phone number
  • A VISA/MasterCard credit card

Click the link: Amazon Web Services to register. When registering, be sure to select the "AWS Overseas Region," as overseas regions do not require enterprise certification.

9488c3363d1ca794.png

Enter your email and account name.

c9edc2cd83a2ea78.png

Enter the verification code sent to your email to verify your account.

cf59c3ea4eb77411.png

Continue to set your account password.

3e47634f1c8cdace.png

Next, fill in your contact information. Note:

  1. Select "Individual" or "Business" based on your actual situation (the author selected Individual).
  2. Ensure your full name, phone number, and address are filled in truthfully. Do not fabricate information, as this may trigger risk control measures.

9b5cc1f6d8c1349a.png

You will also need to verify your account using a credit card. VISA, MasterCard, American Express debit or credit cards are supported; UnionPay is not. Fill in your credit card, name, and address information according to your actual situation. A temporary hold of up to $1 will be applied for verification and refunded upon successful verification.

12f2c67d56d1c15b.png

Continue to verify your phone number.

5e91003286ee8c5f.png

In the final step, select a "Support Plan." The author selected "Basic Support - Free."

15b76f715b11d3.png

After registration, wait for account verification to complete before starting to experience the AWS free tier.

Using Amazon CloudFront Free CDN

Go to Amazon CloudFront and add the website domain you want to accelerate. If you have both HTTPS and HTTP access, you can select matching options. Note that if you choose HTTPS, you must ensure your certificate is valid.

c2c744b02d359eb6.png

Next, select the protocol type and HTTP. The first line is the Viewer settings. The Viewer protocol policy determines whether to redirect HTTP to HTTPS based on your external access needs. Allowed HTTP methods are the request headers allowed; you can choose based on actual needs. Generally, for file downloads, select the first option; for static websites, select the second; for dynamic websites, the third option is required. If you are unsure, simply select the third option to support all methods.

9d6204ca5dfb03bf.png

For CDN optimization strategies, the defaults are fine.

b3b42742aee0597a.png

Keep other settings as default and click Create.

3d29c6e9c12a7abb.png

8db00088a3b48afe.png

Once CloudFront is successfully activated, you will see the subdomain generated for you by CloudFront. Below is the CloudFront CDN management center.

564e6f5acf05e213.png

Click Edit to re-adjust the CloudFront CDN settings.

ca4f39cfc8b83511.png

Open the CloudFront domain, and you will see your website's images and other static files.

cc0eada2456b3d33.png

Amazon CloudFront provides a free SSL certificate. If you want Amazon CloudFront to use your own domain, you need to apply for a free Amazon CloudFront SSL certificate.

2259a302203a2d45.png

Click Request SSL Certificate and proceed to the next step.

3e5dd8973cba1642.png

Then select DNS verification.

02fe41423b4b4aa0.png

Next, Amazon CloudFront will provide a CNAME record, which is specifically used to verify your domain ownership.

7b51fd0369874b74.png

Go to your DNS provider and modify the CNAME record. Once the domain verification is successful, your SSL certificate will be issued.

5213eeca44c53be9.png

When creating a CloudFront CDN, full-path caching is enabled by default. If you want to set caching for specific website URL paths, you can configure it in the CDN path settings.

a7fde5ab9c1058a5.png

The content to be cached or excluded depends on the Path pattern (case-sensitive), mainly using wildcards * and ?. The rules are as follows:

Path pattern Matched file scope
/files/* All files under the /files/ path
/*.jpg All files with the .jpg suffix in CDN resources
/*.css* All files with the .css suffix and those with parameters in CDN resources
/files/*.gif All files with the .gif suffix under the /files/ path
/a??.mp3 All files with the .mp3 suffix starting with 'a' in CDN resources

Amazon CloudFront can also restrict access by region.

ed47901f7c4e575f.png

CloudFront CDN provides Asia-Pacific nodes. Below is the node accessed after using CloudFront CDN; the effect is quite good.

7d790c8cc71d39c1.png

CloudFront CDN Costs

Although Amazon CloudFront is free, it has a specific free allowance. When using CloudFront, be mindful of whether you exceed the free limit, as prices after exceeding the limit are quite high.

e36d1288e614850e.png

Please pay attention to site request traffic costs. The free allowance provided by AWS may not fully cover normal usage. Additionally, testing shows that using EC2 as the origin server cannot avoid this cost. Bills are generated daily, so remember to monitor your expenses regularly.

Conclusion

As an excellent cloud service provider, Amazon Web Services offers a certain amount of free usage for CloudFront CDN, which is usually sufficient for small blogs. However, users should be aware that exceeding this free allowance will result in additional charges.