preface
Aside from WordPress, many blogging sites are hosted on GitHub Pages, but their speed in the country is hard to beat. Therefore, it is a good way to use the CDN of the domestic service provider to accelerate it.
Content Delivery Network (CDN) releases site Content to massive acceleration nodes all over the country, so that users can obtain the Content they need nearby, avoiding the access delay caused by Network congestion, region, carrier and other factors, effectively improving download speed and reducing response time. Provide a smooth user experience.
The strategy I used was to host Coding Pages in China, and to enable Baidu to capture blog content, I did some configuration.
Ask Baidu to include your GitHub Pages blog
However, Coding services are not stable and often change some strategies. It is now integrated into static deployment, and it seems that due to API issues, real name authentication is always failing and cannot be used for the time being.
So simply use CDN to accelerate. And also can be easily captured by Baidu.
Because my domain name is purchased in Tencent cloud, and Tencent cloud CDN free 10G traffic per month. So I directly use the CDN of Tencent Cloud to achieve.
Note: Domain name registration is required (SSL certificate issued on demand)
steps
First open Tencent cloud – content distribution network.
Add your own domain name
Set the source station
Management > Basic Configuration
Here is the IP address provided by GitHub Pages to add multiple lines.
About custom domains and GitHub Pages
Optional: Go to advanced Settings to enable HTTPS
Back to the source agreement
Certificate Management > Edit > Protocol Follow (if HTTPS is not enabled, the default HTTP will work.)
Set the CNAME
Go to Domain name Resolution
Set the CNAME line type provided by CDN to domestic as required. GitHub Pages is still resolved by default.
Configure the cache
The default cache duration is very long, if not set, CDN files will not be updated for a long time.
For details, see Tencent Cloud Document Cache Configuration Problems
You can also refresh manually at the refresh preheat.
The latter
Test found that the home page can be opened in seconds, the speed is really good. And what if there’s not enough traffic, EMM? Maybe when there’s this much traffic, you won’t have to pull up wool all over the place.
FAQ
CNAME conflicts with MX records, causing mail loss
It is worth noting that the CDN is set up by redirecting to the CDN domain name using the CNAME. If you use both your blog domain name (yunyoujun.cn) and your email address (for example, my email address: [email protected]), you may run into CNAME and MX record conflicts.
If your carrier doesn’t tell you to do so, it’s probably best not to do so, as this can cause mail loss in domain mailboxes.
In the past, when resolution was not standardized, some operators allowed CNAME and MX records to be set on bare domain names at the same time. However, according to the RFC standard protocol, CNAME has the highest priority. Therefore, in the process of parsing request, CNAME parsing record results are preferentially returned. As a result, the MX records set by the user cannot be resolved (setting the weight is useless), affecting the normal sending and receiving of the mailbox.
Now, most operators will prompt cnames to conflict with MX records to avoid this situation.
See RFC1034 and RFC2181 for more information. Rules for logging conflicts
The reason I used GitHub Pages for hosting, but still could use domain email, is because I used GitHub to provide A record resolution.
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
Copy the code
Managing a custom domain for your GitHub Pages site
But now the addition of CDN has returned to this dilemma.
Finally, I decided to change the blog’s domain name to www.yunyoujun.cn.
Bare domain names still use A records and MX records. When the user visits yunyoujun.cn (the CNAME file of GitHub Pages is set to www.yunyoujun.cn in advance), GitHub Pages will automatically jump from yunyoujun.cn to www.yunyoujun.cn.
In addition, Google Chrome automatically hides the WWW domain prefix, so it reduces the visual impact somewhat.
As well as I found that some corporate websites are taking the naked domain name jump WWW domain name way.
Such as:
- Language finch: < yuque.com >,
- JetBrains:
(I saw in a video a few years ago that they still left a naked domain url and now it’s a jump WWW link).
Of course, if you don’t need a domain email, and the domain is very short and cool, using a bare domain is not an option.
An alternative solution was a CNAME Flattening.
Some service providers (such as Cloudflare and CloudXNS) can directly resolve A CNAME into the corresponding A record (IP address). In this case, setting A CNAME on A bare domain name is equivalent to setting A record.
In the past, Tencent cloud allows CNAME and MX coexist, and then prompt conflict is not allowed, and now can be set at the same time. However, it is better to resolve to the CNAME of A record at once.
I tried to add a CNAME to the WWW domain name and turned on the CDN, the bare domain name CNAME to the WWW will affect the mailbox. @ -> WWW (CNAME) -> CDN (CNAME) -> A A CNAME Flattening may not be possible.
However, when CNAME is directly sent to GitHub Pages, the email address can work normally. @ -> GitHub Pages(CNAME) -> A
PS. How do I feel that I have spoken a little translation recently.
The author: Yunyou Jun
This paper links: www.yunyoujun.cn/note/use-cd…
Copyright Notice: All articles on this blog are licensed BY-NC-SA unless otherwise stated. Reprint to indicate the source can!