Publish: 2023-12-28 | Modify: 2023-12-28
Amazon Web Services (AWS) provides a free package that includes Amazon CloudFront. Amazon CloudFront is a fast content delivery network (CDN) service designed to securely and efficiently distribute data, videos, applications, and APIs to users worldwide using AWS's global edge node network. By caching content and optimizing transmission, it significantly improves the loading speed of websites and applications, while providing data encryption and network protection to ensure secure content delivery.
As part of the free usage package provided by AWS, you can start using Amazon CloudFront for free. The free package includes the following:
This free tier is sufficient for most websites.
Reference: Amazon CloudFront Pricing
Before using Amazon CloudFront, you need to register for an AWS account. You will need:
Click on the link: AWS to register. When registering, make sure to select "AWS China (Ningxia) Region" if you are in China.
Enter your email address and account name.
Enter the verification code sent by AWS to your email for verification.
Set your account password.
Next, provide your contact information. Please note:
Next, you will need to verify your phone number.
Finally, choose a support plan. Select "Basic Support - Free" for the example here.
After completing the registration process, wait for your account to be verified before you can start using the free package provided by AWS.
Go to Amazon CloudFront and add the domain name of the website you want to accelerate. If you have both HTTP and HTTPS access, you can choose to match both. If you choose HTTPS, make sure your certificate is valid.
Next, select the protocol type and HTTP settings. The first option is for accessing settings for the viewer. The Viewer protocol policy determines whether to redirect HTTP to HTTPS based on your external access needs. The Allowed HTTP methods are the allowed request methods. Choose the appropriate option based on your needs. In general, the first option is suitable for file download scenarios, the second option is suitable for static websites, and the third option is necessary for dynamic websites. If you are unsure, choose the third option to support all methods.
For CDN optimization strategies, the default options are sufficient.
Keep the other settings as default and click "Create".
After successful creation of CloudFront, you will see the generated subdomain for CloudFront. This is the CDN management center for CloudFront.
Click "Edit" to adjust the settings for your CloudFront CDN.
Open the CloudFront domain to see the static files such as images for your website.
Amazon CloudFront provides free SSL certificates. If you want to use your own domain with Amazon CloudFront, you need to request a free SSL certificate from Amazon CloudFront.
Click "Request a certificate" and follow the steps. Choose DNS validation.
Amazon CloudFront will provide a CNAME record for domain ownership verification.
Modify the CNAME record in your DNS settings. Once the domain ownership is verified, your SSL certificate will be issued.
By default, CloudFront CDN caches the entire site. If you want to set cache for specific URL paths, you can do so in the CDN settings.
The cache or exclusion depends on the Path pattern (case sensitive). You can use wildcards * and ?? for matching. For example:
Path pattern Matches
Amazon CloudFront allows you to restrict access by geographic region.
CloudFront CDN provides Asia Pacific nodes. The following image shows the access to a node after using CloudFront CDN, which has good performance.
Although Amazon CloudFront is free, it has certain free limits. Be aware of whether you exceed the free limits, as the additional costs can be expensive.
Please pay attention to the cost of site request traffic. The free tier provided by AWS may not cover all normal usage. Additionally, using EC2 as the origin server will also incur costs. The bill is generated once a day, so remember to monitor your expenses.
As a leading cloud service provider, AWS provides a free usage package for CloudFront CDN, which is usually sufficient for small blogs. However, users need to be aware that once they exceed the free limits, additional costs will be incurred.
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.