Previously, we have an blog explaining why Netlify doesn’t work in China already. In this blog, we are going to give you solutions in detail about how to make Netlify work in China without the tech you might familiar with.
Getting Netlify to work in China
We have two solutions for you to choose from, both of these solutions offer the best loading time experience to your websites’ readers.
Before we get straight to the solutions, let’s take a look at why Netlify is slow in China first. The answer is simple because they don’t have any CDN (Content Delivery Network) nodes or servers inside China. But what does this mean? Yeah, I know it sounds confusing to you, but I promise if you read through this blog, I will explain to you in plain words and give you actionable solutions at the end so you can put it in action and see the outcome in days.
What causing the slowness or inaccessibility of your website in China?
If we look at how CDN works at a high level and say you are making a change on your website. Here are what happen behind the scene:
When you git-push the changes via any version control systems, such as Github, Gitlab, and Gitee, the hosting provider backend (the popular ones outside of China are Netlify and Vercel) will receive a “build and deploy” message from the version control systems. Then,
The hosting provider will pull the content from the servers of external systems, such as headless CMS Contentful, Strapi, Sanity, and build the website inside the hosting provider’s servers.
Once the site is done building, the hosting provider (Netlify) will deploy the web pages on their content network.
If things go well with the above steps, the changes you just did on your website will be live and publicly accessible within the content networks by the hosting provider and the CMS provider.
So what happens when a user visits my website? The hosting provider will find the nearest server to the user and deliver the web page content from that server. The media assets also do the same when a user requests the content.
With that being said, what could go wrong here?
When your web hosting provider or the media assets provider have no servers in China, the default action they do is to find the nearest server (most likely to be in Hong Kong or Singapore) within their content network and serve the web page content and media from that server to your users. That’s the reason why your readers accessing the content fairly slow in China. Here are the CDN locations that Netlify provides:
So based on what Netlify’s staff said, we can tell if you aren’t going to subscribe to their “Enterprise” subscription plan, the nearest CDN or server that your web page content will be served on Singapore. Meaning when your users from China visit your website, your web page content is in Singapore.
Even if you buy their “High-Performance CDN”, you will be unlocked to use more CDN nodes, the nearest CDN you can get are Incheon in South Korea or Tokyo in Japan.
Now, we understand the problems then the solution is straightforward. Simply put, what your need is: a website hosting provider in China that integrated well with your existing CMS.
Hopefully, by now, you have a good understanding of why your website with Netlify is slow in China, now we can move to the solutions, and the solutions should address the problem well and should give you better integration with the technology you are using.
Solution 1: Optimize for Cost
If your website is just a static site, you can host it on AWS S3 Beijing Region or Aliyun OSS, this basically guarantees you have a quick load time inside China, because both of these hosting providers or file storage providers have many servers inside China, and you can purchase their business level support to get more help if needed.
Since AWS S3 and Aliyun OSS are just file hosting services, this means you are only paying for the bare costs of file hosting and bandwidth. This also means your engineering team needs to allocate time to set up a CI / CD, (Continuous Integration / Continuous Delivery) pipeline on your own tools such as Jenkins, or Github Action to mimic the experience you have on Netlify.
If you go with Jenkins, it’s not free, instead, you need to buy additional servers and possibly hire ops engineers to help you manage it regularly.
If you go with Github Action, it comes with a free tier, but be sure to check the load time between Github’s servers to the servers you are pulling content from in China before you put in more effort into it. From our year’s experience in China and Silicon Vally, our engineers in China has problems getting stable services with Github (assuming no VPN or proxies are used) so Github doesn’t give us the stability we are looking for to meet our day to day work in China and the rest of the team remotely. If we have a project mainly for China, we will use the Github alternative Gitee instead. This gives us a better speed and much stabler performance in China.
I guess it’s enough on the topic of CI / CD tool and version control tool. There many other CI / CD tools out there that you can choose from to mimic what Netlify provides, but at the end of the day, to give your website a speed boost in China highly depends on where you put your web page content at.
So back to the main topic, say you have picked your CI / CD tool, set up a proper workflow that works well with your team, and finally choose the file hosting services, then you can route traffic from your domain to the web page content in China.
Sounds like a lot of work? Yes, but it gives you the flexibility to do in at your own ways and optimize for the cost.
Solution 2: Optimize for Cost and Simplicity
If solution 1 overwhelms you with the complexity and the tools and services that you need to use and maintain regularly, solution 2 will give you a simplifier and more cost-effective solution.
You can use 21YunBox to deploy your site in Netlify fashion. Meaning the deployment settings you are currently doing with Netlify, you do the same on 21YunBox.
What makes 21YunBox work better than Netlify in China?
21YunBox CDN has full coverage inside China that Netlify doesn’t have, this will give your site a speed boost for your readers in China. 21YunBox also make Github available to your developers in China. Like we said above Github doesn’t work in China, or it’s blocked or inaccessible well in China, 21YunBox utilized dedicated networks to makes it possible for you to use Github inside China. So this enables your team to stick with the technology that you are using and gives you a huge speed boost in China.
Talk is cheap, let’s show your engineers some code 😎
Here are some guides and the corresponding source codes to get your engineers started and experienced the speed boost with 21YunBox:
We took the Hexo starter (just a simple static website) to conduct the speed test (the speed boot is not limited to Hexo, it works for other static site generator or framework too), we deployed it on Netlify and 21YunBox so you can see the speed test side by side. This is what the Hexo starter looks visually
The left one shows the load time with Netlify CDN vs the right one shows the load time with 21YunBox CDN. You can see 21YunBox gives you the performance boosted (mostly solid green, meaning the site is loaded within 0.4 seconds).
Hopefully, by now, you have a good understanding of why your website with Netlify is slow in China, and what you can do to fix it.