When looking to host your site on a Content Delivery Network, there are a few questions as to how it works. With some providers, you are supplied a CNAME that utilizes anycast to resolve to a different IP depending on where in the world you are:
As an aside, due to the above behavior, a large file pulled through the CDN may hit numerous POPS. If each POP is configured to then pull the full file from the hosted origin, you can incur a LOT of traffic. Think a 44GB video file was rough, image paying for it being transferred 120 times just for one person to watch it. You’re frontloading the content, but still, that’s a lot of data. I digress.
With that, sure, you can resolve the www CNAME to the supplied address. You then ask yourself how do I point my root domain to the CDN. If you use your locally resolved IP address and 301 redirect to the www. CNAME, you only incur the one call to the particular IP. But what if you want the root domain to leverage the abilities of the CDN? You cannot simply point the root domain to the CNAME, that’s bad juju: http://serverfault.com/questions/430970/cname-for-top-of-domain
In the case of other CDN providers, you use their Name Servers, and it is at these nameservers that root domain flattening occurs. That is to say that they perform the resolution at the name server and send out that IP addresses in response to the lookup. This comes with caveats as well. The flattening CloudFlare utilizes gives the TTL the highest value found, not the lowest as you may expect. See here: https://support.cloudflare.com/hc/en-us/articles/200169056-CNAME-Flattening-RFC-compliant-support-for-CNAME-at-the-root
https://gist.github.com/cben/012c1fdbbb69d76cedaf
Pointing your domain to a CDN common thoughts and questions
by
Leave a Reply