DEV Community

Takuya Matsuyama
Takuya Matsuyama

Posted on

You should not use Apex domain with ALIAS record

Apex domain, it's also called naked domain, is a kind of domains without sub-domain.
I've been using it for my app, Inkdrop whose domain of the website was inkdrop.app but now it's moved to www.inkdrop.app.
I deploy it on Netlify which are often mentioned as a fast web hosting service.
I saw many websites performing very fast with Netlify, but my website didn't have such speed. Especially, the TTFB (Time-to-first-byte) was extremely long, usually longer than 200ms and it takes 800ms to transfer only 120KB. Why?

Screen Shot 2020-02-29 at 21.19.10.png

ALIAS record disables geo-targeting

If you have your own domain, you have to configure a CNAME record to point it to the Netlify's domain.
But Apex domain is not supported setting a CNAME record by design.

To host a website with an Apex domain on Netlify, one option is to use ALIAS record instead:

https://docs.netlify.com/domains-https/custom-domains/

I'm using NS1, a DNS hosting service which supports configuring ALIAS record.
I found their documentation mentioning about ALIAS:

Disadvantages of an ALIAS record

  • Geo-targeting information is lost. Since it is the_authoritative_server forexample.com(issuing the queries forlb.example.net), then any intelligent routing functionality on thelb.example.netrecord will act upon the location of the authoritative server instead of your location. The EDNS0 edns-client-subnet option_does not_apply here. This means that you may be potentially mis-routed. For example, if you are in New York and the authoritative server forexample.comis in California, thenlb.example.netwill think you are in California, and will return an answer that is distinctly sub-optimal for you in New York.

Ouch.

So, with ALIAS record, Netlify is not able to know where visitors are from or to optimize the traffic route.
I asked Netlify that it is due to ALIAS record:


Unfortunately, that seems to be true.
I decided to move my website to www sub-domain.
Apex domains look beautiful (for developers), but it seems like not a big deal for visitors.
I found that recent browsers strip www from their address bar like Chrome:

Chrome
and Safari on iOS:

Safari
As stated by a Chromium developer, the www and m (for mobile) subdomains are being classified by Google as "trivial" subdomains because they feel most people do not need to be concerned with the information they represent.

I guess I am also not caring about www subdomain when visiting websites because I didn't notice that Netlify's website is actually https://www.netlify.com/.
So, it would be fine.

TTFB improved from 275ms to 73ms

As you can see, it has been significantly improved after moved it to www.inkdrop.app:


The download speed has been also improved. Cool.

Still need Apex domain?

As fool said above, you have two options at present:

  1. Netlify DNS hosting, since they can (and do) use linked A records which do allow geolocation
  2. Cloudflare’s CNAME flattening, since that does not seem to interfere with Netlify's geolocation

Why I didn't choose it is because I've already adopted NS1 and just switching to www was the quickest way to solve my issue.

Hope that helps improve your website!


YouTube channel - Dev as Life

Top comments (0)