Search code examples
dnsfirebasecnamefirebase-hostinga-records

A record vs CNAME record for custom domain


Which should I pick and why? Firebase recommends CNAME records but why? Isn't it better to point to the ip address rather than point to another domain that points to the ip address?


Solution

  • Firebase recommends CNAME records but why?

    Firebase hosting is probably marking CNAME records as recommended because they are widely allowed for setup by registrars and the easiest to setup for most novices when setting up their wildcards.

    Isn't it better to point to the ip address rather than point to another domain that points to the ip address?

    YES you are correct. It is going to be a faster lookup because it will not have to do 2 lookups (the CNAME then the pointed domain name).

    Firebase Hosting gives you the option to add A records in your DNS with not just one IP address but two for even better performance.

    Which should I pick and why?

    You will have a choice here.

    • Use A records pointing to IP addresses if allowed first if you are not concerned the IP address will change for the hosting server. Will Firebase Hosting change IP addresses in the future? Maybe, but probably not very often.
    • Use CNAME if you are not concerned about the lookup making two lookups or you want an easier setup.
    • Use CNAME if you are using a multi-region CDN for a static site with google or a host like Netlify and you are not using their DNS servers for your domain. This will allow their servers to resolve users to the closest server in their region.

    NOTE: Both of these options could require a change if Firebase Hosting decides to make a domain name or IP Address change to their hosting services, but I would suspect they would notify you ahead of time as soon as that is going to happen.

    My choice is to use A record pointers in this case because we are dealing with Google here and typically are good about notifications of changes. I can change an IP address as quickly as a domain name in a DNS configuration.