Content Distribution in China

I have a site deployed to Netlify and I want to serve it to users in China.
For reference, my domain and site is registered in accordance with China ICP regulations, so there’s no worry for GFW blocking our site.
Out of the box, however, there is a noticeable network performance difference between users connecting from within China from outside. This is understandable, as it seems Netlify’s closest locations are in Singapore.

I want to continue to use Netlify to manage my site’s deployments and serve content globally, however I need to find a way to connect an in-China CDN to my deployments. Perhaps one way is to set up a Cloudfront distribution in AWS China (Beijing or Ningxia region) to a new domain and forward connections to my site.netlify.com domain managed by Netlify?

Any thoughts on this would be greatly appreciated

hey there,

I know this isn’t 100% what you are asking about, but thought i’d point this thread out to you:

Thanks for the link, I’ve read that thread but it’s not too applicable since the GFW (as far as domains are concerned) operates according to the ICP regulations and censorship guidelines. I have successfully registered my site according to these regulations with the CN gov, so this shouldn’t be an issue.

The main problem is that since my site is being served from Singapore (presumably) and accessed in mainland China, the delivery speed can be quite slow (~5-20s) for a simple page load (the normal delivery speed being ~0.5-3s). I wouldn’t expect Netlify to own distribution centers in China since I know very what that process involves, but I hope there can be an acceptable solution for me to leverage the resources I have (AWS China) to work well with my site primarily deployed by Netlify.

I do think we have ability to get a point of presence in China, but it would take an enterprise level contract to set up since as you know it requires a whole lot of work (setting up a local office in China, working with Alibaba to set up a node internally). I understand that is not what you are looking for, just wanted to put it out there that we have investigated the possibility and determined that we could do it, given the return on that investment (and it would have to be limited to single, pre-qualified clients as you know from researching the ICP).

What you could do today for 0$ is something like use a geo-redirect (Redirect options | Netlify Docs) for assets requested from china to point to your other destination from Netlify; it means the first request would be slow but you’d HTTP 301 them to a content source inside of China which would presumably be faster. Or, if it isn’t reasonable to do that “at the same hostname”, you could use that feature to instead 301 redirect Chinese requests to an entire separate website that is hosted off Netlify, within China, for that Chinese traffic. These are both workflows we can provide tech support for.

You could also use some DNS service that supports geographic based routing, like NS1: https://ns1.com/geographic-routing - this would let you return a more-local response to DNS lookups in China rather than your Netlify record(s). While NS1 is our DNS provider, we don’t expose that particular feature to you in our DNS hosting, so you would need your own account there to configure it, but we use that feature for our running our CDN and it works quite well.

Note that proxying TO Netlify is not a recommended workflow as it often fails and we cannot help troubleshoot when it does (see [Support Guide] Why not proxy to Netlify? for details), so I can’t recommend that, though it might suit your needs better in terms of response time - we can’t make a lot of guarantees about your site working well that way :confused:

Let me know what you think!

Been awhile, thought I’d update with my current solution.

I ended up using the AWS China Cloudfront solution with Netlify’s georouting headers and a “.cn” domain to accelerate the site in China. This works quite well, actually, since the site is largely static and versioned so I can set aggressive caching policies on assets with a 0 TTL on the index pages to keep the content up to date.

If anyone else has a similar need and is considering this, there are few things to consider:

  1. Make sure you version your assets, use aggressive policies, and set TTLs that fit your site’s needs, otherwise you will not get much benefit from using Cloudfront with Netlify.
  2. If you set “cache-control” or “pragma” headers in your netlify.toml file, these will override your Cloudfront cache settings.
  3. You will need to handle SSL on your own and install your certificates on your Cloudfront distribution manually (at the time of writing this, ACM is not available for Cloudfront in China).

All in all, it was a bit of work to get everything up running smoothly, but the results are leagues better than before so it was absolutely worth it.

4 Likes

oh man @HoukasaurusRex, thanks so much for sharing your solution for this - we really appreciate it!

Can you share what your site performance in China was before and after implementing this solution? We’re going through a similar process now for our own netlify deployment

@HoukasaurusRex Thanks for sharing your solution with AWS China.

There is a one-click deployment hosting service like Netlify in China, it’s called 21YunBox, here is the website for https://www.21yunbox.com/

They help you get ICP if you needed and provide solutions that within the Chinese Great Firewall, stuff like Headless CMS alternatives, and Algolia alternatives.

1 Like

Hi, my project is encountering this hurdle at this time. I came across this thread. Thanks @HoukasaurusRex for posting your solution. My assumption is that it follows this guide: Deploying Netlify Sites with AWS CloudFormation

It’s been a year now so I’d be curious if anyone from Netlify could speak as to how current that guide is (written in 2018); whether JT’s solution is still the most ideal; and/or the state of the CDN as it pertains to visitors from China.

As of this past month we’ve had some staff in China do some preliminary testing and couldn’t access our site without a VPN.

Just attended the Headless Commerce Summit and found that although there was some talk about i18n and load speed (all promising stuff), access is still a big question mark in my head. If Apple, for example, couldn’t make their site accessible to Chinese customers, that’s billions in missed opportunity. Obviously they solved it because I’m not their engineer and why I’m here asking the questions. :laughing:

In all seriousness, CDNs are meant for all folks around the world to be able to experience a site at near-parity. I’d love to figure out how to do it with Netlify’s. Not a dig. I love what you guys do and want to see you succeed.

Hey @fivetwelve,
Thanks for bumping this issue. Unfortunately, no update on China CDN nodes, but it’s definitely something that’s on our radar and we’ll be sure to update this thread if there’s any movement in that direction. As for solutions in the meantime, I’d point to @fool and JT’s suggestions above. Is that setup what you tested and found that you could only access via VPN?

Hi all :wave:

Just passing through and wondering if there’s been any updates on this situation in regards to China CDN nodes?

Thank you! :smile:

Hey there, @rmunsch :wave:

Thanks for following up here! We do not have any updates at this time-- I know this isn’t the news you were hoping for. That being said, I do encourage you to explore some of the interim solutions that other Forums members have shared in this thread.

I’m interested in this too. I know up above there is a mention of geo routing the cdn content. I guess my question is, how do you upload content to another CDN on a netlify build?

Hi, @adamatronix. The distribution of the site to all the CDN nodes that Netlify uses is automatic.

If you are asking about how to upload your site’s build to some third-party CDN not controlled by Netlify, that isn’t a question we can answer without the details of that third-party CDN. I recommend asking the other service how to upload content to their service.

Then, once you have that information, you could ask us here at Netlify is there was a way to do “X” using the build process at Netlify where “X” is the process required to upload to the third-party CDN.

To summarize, if you want to know how to upload to all the Netlify CDN nodes that is always automatic. If you are wanting to know if you can upload to a third-party CDN, to answer that we need more information from you.

If there are questions about any of this or if you have the instructions for the third-party CDN, please let us know.

2023 Update

You can check out this new 21YunBox | Netlify Integrations.

It’ll allows you to deploy straight to China CDNs directly from your Netlify Dashboard.