Our server hosts multiple domains (myce.com, club.myce.com, liggydee.cdfreaks.com, etc.) so typing in the IP address results in the server issuing the default page as the browser does not provide the domain name to fetch. Our server’s default page basically says that the server is working and then automatically redirects to club.myce.com. As a result, the browser would then do a DNS lookup on club.myce.com which resolves to Google’s Pagespeed IP and in turn would fail to load in China.
So by using the hosts file, the DNS lookup resolves by the hosts file to our direct server IP address, so when the browser fetches let’s say “www.myce.com”, the server knows that the browser is requesting that domain in the GET request (which an IP address alone does not specify) and delivers the webpage.
You can also try this yourself. For example, club.myce.com resolves to 18.104.22.168 at this time of checking. If you type in http://22.214.171.124/ into your browser (or just click this link), you’ll get an error page as Google’s PageSpeed does not know what website you’re looking for as Google’s server received a GET request for ‘126.96.36.199’ intead of ‘club.myce.com’.