Use a CDN to improve the performance for Chinese users

January 13, 2018 431 views
DigitalOcean Ubuntu

Hello,

I have a droplet in LON1 for almost two years, and host an important website. I also use CloudFlare on top of it.

When visiting the website from Mainland China, it is slow in general, and sometimes it is too slow to display the page. Now, I want to overcome this.

I did some research, I think I will deliver the website in China via a Content Delivery Network (CDN). Now, it seems that there are two options:

1) DigitalOcean LON1 + CloudFlare + Baidu CDN

2) a server + Alibaba CDN

I think the first option is doable, my question is in the second option, is it possible to keep using my current DigitalOcean LON1 server and just use an Alibaba CDN? Do I have to use a Alibaba server?

Another question is, which option do you think is better?

Cheers

Tie

1 Answer

If your site isn't on a blacklist it should be fine to just host your content in LON1 and have the china-based CDN store your assets.

You need to change your application to reference the resources on the cdn instead of linking to your own server, so your LON1 box will serve the dynamic web content and the CND boxes will serve your images / css / js etc.

You'll end up having to call something like this from your templates:

  function image_url(name){
     if (user_is_from_china) { return "https://you.thecdn.cn/static" + name } 
    else  { return "https://your.domain/static" + name }
  }

CloudFlare does a man-in-the-middle version of this, and they change your content on the fly - if you're planning on having support for multiple CDNs you'll likely need more control over the urls used in your pages.

  • Sorry, I don't understand your reply. Could you please answer my questions directly?

    1) is it possible to keep using my current DigitalOcean LON1 server and just use an Alibaba CDN?
    Do I have to use a Alibaba server?

    2) should I go DigitalOcean LON1 + CloudFlare + Baidu CDN, or server + Alibaba CDN?

    Cheers

Have another answer? Share your knowledge.