Click here to Skip to main content
15,881,089 members
Articles / DevOps
Tip/Trick

Easy Way to Lose Your Customers or Why You Should Not Use Google CDN

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
7 Oct 2016MIT3 min read 11K   2   2
Using Google CDN might break your site in China

"The Great Firewall of China"

Introduction

According to Wikipedia Google, Facebook, Twitter and YouTube are blocked in China since 2014. This means that not only search engine, maps and Gmail are unavailable, but also CDN, APIs and fonts. If you use any of that in production, then in the best case, your site has a different layout and in the worst - your customers are waiting for 30 seconds before your JS, which is loaded synchronously, finally fails due to timeout only to find your site is broken.

Background

The Great Firewall of China is a term used by media to refer to legislation and projects initiated by the Chinese government (which is controlled by the Communist Party of China, CPC) that attempt to regulate the Internet in Mainland China. It is the main instrument to achieve Internet censorship in China. These CPC regulations include criminalizing certain online speech and activities, blocking from view selected websites, and filtering keywords out of searches initiated from computers located in Mainland China.

I Don't Care About China

It is a huge mistake to think that you don't have customers in China. Nowadays many people from different countries of the world are either living of regular flying here for business. Your clients might still be interested in buying your goods or services remotely and by making your site unavailable to them, you make a huge favor for your competitors. Keep in mind that your customers might not return after the switch.

How to Resolve the Issue

  1. Check if your website includes any JavaScript or font resources from Google (i.e. *.googleapis.com). You need either to use another CDN, which is available worldwide without restrictions or to serve these resources locally.
  2. Don't worry about google-analytics and social buttons. You can keep them as they are loaded asynchronously and therefore don't make any impact on usability or performance. However, there are two side-effects worth to mention. First, they are not rendered on the page. Second, your page loading indicator in the browser will spin for extra 30 seconds before JS finally fails to load.

Does VPN Solve the Issue?

Well, yes and no.

  • VPN is illegal in China. Making your customers break the law to use your site might be not the best idea.
  • Most users are not techies. They might have hard times to setup and use VPN.
  • China is always finding a way to block VPN providers. So what works today, might not work tomorrow.
  • Thanks to the "Great Firewall of China," international Internet resources might work very slowly here. If your site works fine without VPN, it will work on average faster for your customers.

How Can I Reproduce the Issue Without Going to China?

  1. Delete your browser cache to make sure that no cached resources are used
  2. Temporary add to your hosts file line "127.0.0.1 ajax.googleapis.com" and check different sites, which rely on it. For example, stackoverflow.com. While URLs are still working fine and site is more or less usable, some functionality is broken. It might be a good example but also keep in mind that jquery is loaded synchronously, therefore in the real world, you had to wait for 30 seconds before the site is initially rendered.
  3. You might also install software, which helps to emulate slow networks. Set the speed to 128 kBit/s, and now you can test, how "fast" are foreign websites in China.

Conclusion

I hope that I was able to convince you to switch from Google CDN to other CDNs or serve your resources locally. It is very easy to make some folks like me happier one day. :)

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior)
China China
Full stack and mobile senior developer

Comments and Discussions

 
GeneralMy vote of 5 Pin
Duncan Edwards Jones1-Feb-17 3:21
professionalDuncan Edwards Jones1-Feb-17 3:21 
GeneralMy vote of 5 Pin
rosdi7-Oct-16 15:55
rosdi7-Oct-16 15:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.