Alibaba Cloud CDN cache warm-up and refresh and common fault summary

CDN cache warm-up refers to actively pushing the files to be cached to CDN edge accelerators across the country, reducing the return-to-source rate and improving the hit rate.

Cache refresh refers to uploading a file with the same name later. The previous cache already exists in the CDN edge accelerators in various places. By refreshing, the new file and the old file can be overwritten.

1. Add expiration time for files cached by CDN

First, add a cache expiration time for the CDN cache file. Even if you don’t refresh it in the future, the cache will return to the source after it expires.

1) Click CDN domain name management —> click cache configuration —> cache expiration time —> add

image-20220216103737415

2) Select the file extension for the type —> fill in jpg, png, gif, js, css, txt for the extension —> set the expiration time to 30 days.

image-20220216103917880

3) Setup complete

image-20220216104003640

2. CDN cache warm-up configuration

Now that the website has been connected to the CDN accelerator, we upload a picture in the directory of the program, and then push the picture to the edge accelerators all over the country through preheating to reduce back-to-source.

1) Upload pictures in the site directory and visit

After uploading the picture, it can be accessed, but CDNs across the country do not have the cache of this picture at the beginning, and the source rate will be greatly improved.

image-20220216102942452

2) Configure CDN cache warm-up

Push images to CDN accelerators in various places through CDN cache preheating.

Click Refresh Preheating—>Refresh Cache—>Operation Type is Preheating—>Refresh Type is URL—>Fill in the URL path of the new file—>Click Submit.

image-20220216103222010

Our warmup operation can be seen in the operation log.

image-20220216103421005

3) Access to newly added files

At this point, the image file has been pushed to the CDN edge node, and there is no need to go back to the source.

image-20220216104022221

3. CDN cache refresh configuration

We set the expiration time for the files in the CDN cache to 30 days. If the file with the same name is modified within 30 days, the request will not be returned to the source, and the user still accesses the old file. Based on this situation, you need to use the CDN The cache refresh function is now available.

1) Upload a new picture

Upload a new picture and name it 1.png, visit the picture url again, and find that it is not the picture we want.

image-20220216111459948

2) Configure CDN cache refresh

Click Refresh Preheating—>Refresh Cache—>Operation Type is Refresh—>Refresh Type is URL or Directory—>Fill in the URL path of the new file—>Click Submit.

image-20220216111656913

3) The refresh operation can be viewed in the operation record

image-20220216111752288

4) Refresh the picture again and you will find that it is the latest picture file

Wait for about 1 minute to refresh successfully.

image-20220216111951442

4. Common faults

As shown in the figure below, after the website is connected to the CDN, it cannot be accessed and is always redirected.

Possible reasons:

1. The website must have the configuration of HTTP forced to HTTPS.

2. The website uses HTTPS to access. At this time, both CDN and SLB need to configure HTTPS, otherwise it will lead to inaccessibility.

3. SLB has enabled HTTPS access, and configured HTTP to be forced to HTTPS. If the port of the CDN’s back-to-source address is filled with port 80, there will be problems, and it needs to be configured as 443.

4. Finally, refresh the CDN cache

image-20220216130722262

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/132532950