banner
朝闻道

朝闻道

做个知行合一的人
email

CDN Acceleration Solution for Blogs

Newbie Help 😄

Oh, my website is so slow#

One drawback of hosting a blog on Github is that the webpage loading speed is slow. To solve this problem, you can use CDN.

To put it simply, the reason why webpages are slow is that the server (Github server is located overseas) and the client (the users accessing the website) are too far apart, resulting in slow resource retrieval.

CDN, which stands for Content Delivery Network, functions by caching specified resources in distributed sites (cache servers) located in different cities. As a result, when a user accesses the website, the data will be directly retrieved from the nearest server, eliminating the need to retrieve it from the original server located far away (if it is indeed far away).

Okay, so the next step is to find a free CDN, hehe.

jsdelivr (Deprecated)#

Now it's time to introduce today's protagonist - jsdelivr.

The configuration is extremely simple. You don't need to download any software or apply for any accounts. You only need to enter the code in the required format (which is actually a URL) in the address bar of your browser. This will allow you to upload your blog files on Github page to jsdelivr's server and use their service - CDN acceleration to access your blog files.

If your blog is also hosted on Github, the following content will be helpful to you.

First, publish a release version for your Github blog repository (only then can you use jsdelivr) (it's simple, you need to search the internet for instructions). Then I will tell you the code you need to enter in the address bar of your browser:

Note: The following "Your Github Name", "Your Repository Name", and "@Release Version" need to be entered according to your own Github. You can refer to the last code at the end of this article (how I use it).

  • If you want to upload a specific version of your blog file library:
    • https://cdn.jsdelivr.net/gh/Your Github Name/Your Repository Name/@Release Version/
  • Or upload a specific file in the version:
    • https://cdn.jsdelivr.net/gh/Your Github Name/Your Repository Name/@Release Version/Filename+Extension
  • Or upload a specific folder in the version:
    • https://cdn.jsdelivr.net/gh/Your Github Name/Your Repository Name/@Release Version/Folder Name/

Note that the ending / is required.

After successful upload, the uploaded document page will appear. Then you may find that your webpage opens very quickly, at least faster than before.

You can directly upload the entire repository's files and update them in real-time using the following code, instead of uploading one version at a time. In fact, I think this is the most convenient method.

https://cdn.jsdelivr.net/gh/Your Github Name/Your Repository Name/

For example, this is how I use it: https://cdn.jsdelivr.net/gh/1xiaoyuan/1xiaoyuan.github.io/

I discovered this later, removing the version number allows you to directly upload the entire repository 🤷‍♂️ Real-time updates are really cool.

New Solution: cloudflare#

On July 30, 2023, the new domain will be hosted on cloudflare for CDN, greatly improving the speed.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.