banner
朝闻道

朝闻道

做个知行合一的人
email

CDN Acceleration Solution for Blogs

Newbie Help 😄

Oh, my website is so slow#

One disadvantage 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 (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 users access the website, the data will be directly retrieved from the nearest server, without 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 (which is actually a URL) in the address bar of your browser according to the specified format. This will upload your blog files on Github page to jsdelivr's server, and then you can 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 in this way 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: "Your Github name", "Your repository name", and "@release version number" 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 the blog file library:
    • https://cdn.jsdelivr.net/gh/YourGithubName/YourRepositoryName/@ReleaseVersionNumber/
  • Or upload a specific file in the version:
    • https://cdn.jsdelivr.net/gh/YourGithubName/YourRepositoryName/@ReleaseVersionNumber/FileName+Extension
  • Or upload a specific folder in the version:
    • https://cdn.jsdelivr.net/gh/YourGithubName/YourRepositoryName/@ReleaseVersionNumber/FolderName/

Note that the / at the end 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/YourGithubName/YourRepositoryName/

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 awesome.

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.