Using CDN to Accelerate BOS
Overview
This article explains how to use the Content Delivery Network (CDN) to speed up data distribution in BOS.
Requirement scenarios
In storage and distribution scenarios, BOS is used to store files like static images, website video files, and downloadable application service content. These scenarios typically have the following characteristics:
- Static files have a large access volume, high access frequency, and high server load
- Static files face a very large user base, high concurrent access intensity, and extremely complex network environments
- High-speed and concentrated downloads are required within a certain period, with a high volume of concurrent downloads, such as application update packages and program patches
Accelerating BOS with CDN services enables users to access files stored in BOS more quickly, significantly enhancing the user experience.
Advantages
Using CDN to accelerate BOS to build a storage and distribution scenario has the following advantages:
- Massive storage space, with no restrictions on the number of stored objects;
- Extremely low storage costs. BOS storage costs are much lower than cloud disks, and it supports multiple storage classes such as standard storage and infrequent access storage;
- Greatly reduces the load on Web servers, as all access to static files is borne by CDN;
- By leveraging Baidu's nationwide CDN nodes for distribution, the delay in accessing content is greatly reduced, response times for website access improve, website availability increases, and issues like limited network bandwidth, high user traffic, and uneven network node distribution are resolved.
Practical operations
For instance, when constructing a website, the site usually includes main pages, static and dynamic files, and program code. Using the CDN-accelerated BOS solution can optimize website architecture and improve user experience with minimal cost increases. Specific solutions and steps are as follows:
-
Organize website programs on BCC or any other location, distinguish between dynamic files and static resources, and store static files in BOS.
- Create a resources directory to store all website static resources;
-
[Create a bucket](BOS/Console Operation Guide/Managing Bucket/Create bucket.md) on BOS to store website static resources.
Plain Text1> **Note:** The “read and write permission” of the bucket must be at least “public read” to enable anonymous access to resources from the external network. If the Bucket has already been created, you can modify it in `Bucket Settings`. 2> 3> If you need to prevent hotlinking or protect access permissions, you can use the referer field or access via signatures calculated by AK/SK. For details, please refer to [Anti-leech](CDN/Operation guide/Configure Domain Name/Access control/Set anti-stealing-link.md).
-
Enable CDN
CDN acceleration can be enabled using two methods: “default accelerated domain name provided officially” or “a custom filed domain name obtained by an individual/company.”
-
Use the official default accelerated domain name
- When creating a bucket, set the CDN official acceleration option to
ON, and you can directly obtain the official CDN accelerated domain name. - If the bucket has already been created, you can enable CDN acceleration in the “Publishing Management” page of the bucket. For details, refer to [CDN Official Domain Name Acceleration](BOS/Console Operation Guide/Data Publishing/Enabling CDN Official Acceleration Domain Name.md).
- When creating a bucket, set the CDN official acceleration option to
-
Use a custom accelerated domain name
A custom accelerated domain name refers to a domain name that has been filed and applied for by an individual or company.
Select the bucket to accelerate, go to the “Data Publishing” page, and click on “Add Custom Accelerated Domain Name.” Ensure the domain name is successfully resolved for CDN acceleration.
-
-
Upload files and experience CDN acceleration
BOS provides multiple file upload solutions. You can choose [upload from the console](BOS/Console Operation Guide/Manage object/Upload files.md), [upload using API or SDK](BOS/Developer Guide/Object Basic Operations/Uploading Data/Simple upload.md), upload using BOS CLI, etc.
Here’s an example of uploading a file via the console.
-
After the upload is completed, enter the Data Management tab of Bucket Management to check whether the uploaded file object exists. If it exists, the CDN accelerated access address of the file is usually
the custom accelerated domain name or official CDN accelerated domain name + '/' + 'file name'.If multiple CDN-accelerated domain names are bound to the bucket, all of them will be effective.
-
In the application system, replace the URL for accessing the original static resources with the accelerated access address (
your custom accelerated domain name or official CDN accelerated domain name + '/' + 'file name'), that is, access after CDN acceleration.After the modification, all access to website static files will be through BOS + CDN, which not only reduces the consumption of your machine resources but also improves the speed of user access and enhances the user experience
-
-
Test CDN acceleration
Use a browser to access resources on BOS through
your custom accelerated domain name or official CDN accelerated domain name + '/' + 'file name'.
Related references
-
CDN preloading
- Enabling the preloading function allows users to experience CDN acceleration during their first visit (preheating to CDN). For specific operations, refer to CDN Preload Cache.
-
CDN configuration rules
- If the expiration time is not set in CDN and the source does not explicitly provide an HTTP cache control header, CDN will not cache the data.
- You can configure the expiration time in CDN to automatically update the cache. For specific operations, please refer to [Configure Cache Expiration Time](CDN/Operation guide/Configure Domain Name/Cache configuration/Configure Cache Expiration Time.md).
