1

Heroku in their docs talk about why you should avoid naked domains if you are dependent on IaaS or PaaS.

There is also an existing question on ServerFault, but it doesn't tackle my query.

I have understood their explanation. The part I am confused about is the caching of the ip. Heroku claims they can change the ip of their endpoint in their DNS settings and all will be good. However, don't most browsers/proxies/clients cache that ip? TTL values are not always respected. Also how quickly does that ip get propagated? Wouldn't the requests still go to the old ip?

2 Answers2

4

You can use a CNAME for, say, www.example.com, so that it points to magic-squirrel.herokuapp.com (or whatever). magic-squirrel.herokuapp.com will resolve to whatever IP Heroku has assigned to that end point, for example, 1.1.1.1. That IP can change if Heroku needs to do some network reconfiguration, but magic-squirrel.herokuapp.com will be updated to point to, say, 2.2.2.2. www.example.com will follow naturally, after TTL expiration. In this case, you won't have a service disruption because of something Heroku did to manage their network.

You cannot use a CNAME for example.com, the naked domain. You instead will need to use an A record. As above, your app is running on magic-squirrel.herokuapp.com, which has an A record of 1.1.1.1. Because you can't CNAME to that name, you will have to create an A record for example.com to point to 1.1.1.1. Sometime later, Heroku does their network configuration, and magic-squirrel.herokuapp.com now points to 2.2.2.2. Your example.com is now mysteriously broken. You will need to notice that magic-squirrel.herokuapp.com no longer is on 1.1.1.1 and update your DNS accordingly.

cjc
  • 25,492
2

Even though the CNAME might have a high TTL, the cached value is the alias, not the IP behind the alias(or at least should be the alias).

So while having a higher TTL on the CNAME to make use of caches, the target of the CNAME can have a very low TTL to allow changing it more often and especially allow to change it automatically without touching your own DNS records.

Izzy
  • 815