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 (https://docs.netlify.com/routing/redirects/redirect-options/#redirect-by-country-or-language) 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 [Common Issue] 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.

1 Like

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