Debugging slow loading time on root domain setup with A record

We have a SPA setup with the following _redirects file:

/*   /index.html   200

With DNS hosted at Amazon S53 with the rules:

A: * => 104.198.14.52
CNAME: develop => domain.netlify.com

Note that I am using domain.netlify.com and domain.com, but of cause that is not really our domain.

Issue

But we are seeing really slow loading times for assets like images when loading from Europe. We see TTFB in the range of 2-5 sec for small images.

Debugging

The TTFB seems to vary a lot from request to request but it is consistently performing good on develop.domain.com (using CNAME record) and worse on domain.com (using A record).

I can see in the forum that we are not the only ones experiencing this. What information do you need from us to better debug this?

Thanks a lot.

Hi, @eeit, and welcome to our Netlify community site. :+1:

Here is the issue:

  • the apex domain is (probably) set to primary
  • an A record is being used for the apex domain

If you do these two things (use an A record for the apex set it as primary) you will completely miss out on our global CDN.

The IP address 104.198.14.52 is in (or near) San Francisco.

If you do use the A record method for the apex domain (like example.com), then we recommend that you set a subdomain (like www.example.com) as the primary domain for the site.

We do not recommend using the apex domain as the primary domain for the site. Subdomains will use a CNAME record, not an A name.

The CNAME records for the subdomains will be redirected to the IP address of the closest CDN node - closest to the source IP address making the DNS query. So, someone in Paris will be sent to a CDN node in Frankfurt not San Francisco which will likely be a much faster connection.

If you make an A record for the apex/root domain then please make a subdomain the primary domain for the site (and do not set the apex as primary).

If you do set the apex as primary with an A record for CDN all global traffic is sent to a single CDN node near San Francisco and the rest of our global CDN nodes will be ignored.

Please let us know if there are other questions we can answer about this.

Hi @luke

Thanks for the detailed answer.

I can see from your 2017 guide To WWW or not WWW that you clearly recommend using the subdomain www.example.com as the canonical domain and that a CNAME record is set up for this subdomain pointing towards the Netlify site example.netlify.com.

Am I correct that we still need an A record for the apex domain example.com pointing to your San Francisco IP address 104.198.14.52 which will respond with an HTTP 301 redirect to www.example.com if the two domains have been configured in the Netlify system?

Thanks.

Yes, if you are configuring a primary custom domain, both the www subdomain and the apex domain will need to be configured as you described – a CNAME for your www subdomain pointing to example.netlify.com and an A record for your apex domain pointing to 104.198.14.52.