“Blog move” original address: Jane book original published time: 2017-04-19

This article explores how to accelerate access to blogs based on Github Pages and Hexo. Hexo + NexT + Github Pages is widely used to create blogs. As we all know, this type of blog has not been optimized and is slow to open. This paper discusses the optimization methods, including modifying font resources, changing the hosting platform of blog and other ways to speed up the visit of blog.

1. Explore why Hexo + NexT’s blog is slow to open

As I pay more attention to the opening speed of the blog, so the resources used in the blog have been optimized to varying degrees. For example, all the pictures in the blog are linked to the picture bed “Jian Shu, Qi Niu, etc.”, the resolution and quality of the blog’s head picture and the icon of the website are optimized, and all the animation effects of NexT are closed.

After the above optimization, open my blog and use Chrome developer tools to see that most of the resources requested to visit my blog are available within 1 second, but there are still three resource requests that fail:

By querying these HTTP requests, it can be found that the request fails because resources related to Lato font cannot be obtained from Google’s server. “These resource files can be normally obtained after scaling the wall” :

2. Modify the font resources that your blog relies on

Open NexT’s theme configuration file “_config.yml”, find the font Settings area as shown below, and delete the global font family “Lato”.

Then visit the blog again and it will be much faster. Of course, you can also set the font family to be used on the web page. See the reference link at the end of this article for details.

3. Comparison of blog hosting platforms

Since the blog is deployed on Github Pages, it will obviously be slower to access in China. The alternative is code Cloud, a code hosting platform in China, which provides Coding Pages service, which is more convenient to use than Github Pages. However, when the same Hexo + NexT blog is deployed to the code cloud, some Js resources cannot be found when opened, as shown below:

The reasons for the above errors are not explored too much. Because this platform has this error, I adopt the solution is to deploy the blog in “Qiniu Cloud storage”, which can significantly improve the access speed of the blog.

I used the “website speed measuring tool” of Webmaster’s Home to measure the speed of my two blogs deployed on “Qiniu” and “Github Pages” respectively, and the results are as follows, judging the speed.

4. The pit encountered when deploying the blog to Qiniu cloud storage

Follow the method in the link at the end of the article to successfully deploy the blog in Qiniu and use the temporary domain name provided by Qiniu to access the blog, but I still encountered some problems.

Problem 1: Although the blog was successfully deployed, a 404 error was reported when accessing my domain name. The reason was later found to be that there was a problem with DNS. After replacing DNS, you could access “such as Using Ali DNS” normally. My network here has always been not good for seven cattle support, I do not know what reason.

Problem 2: Quniu adopts “fusion CDN” technology by default to accelerate the access to the website. This scheme will significantly affect the request effect of dynamic files. For example, after updating an article, the update can be seen on the web page after 30 days by default. The official provides a solution to refresh the cache in time:

Refresh CDN cache rule Settings and effective time

Therefore, the acceleration function provided by Qiniu is best for static files only, but for our static blog, it is not troublesome to manually refresh the cache after updating the blog, and qiniu cache refresh time can be set, the advantages outweigh the disadvantages.

5. Reference links

  1. Load Google fonts from the server in the NexT theme
  2. The Google word library caused the Hexo NexT homepage to load slowly
  3. Web Chinese Font Application Guide
  4. Cross-platform font effect analysis
  5. A brief analysis of the evolution and development of Chinese and English basic glyphs
  6. Getting started: Five principles for choosing fonts
  7. Hexo Blog Series: Deploy to Seven Cows
  8. Multi-platform synchronous upload client “Seven Cows”