According to Apple: “OS X keeps a local cache of resolved DNS queries for a time defined by the DNS server, but sometimes it may be necessary to reset the cache immediately and re-query a DNS server. For example, you might do this after an entry on the server is changed or a new entry is added.”
Below are steps for clearing the Cache in Yosemite (10.10.x) and older. If you have High Sierra (10.13.x) or newer, use this link to clear the Mac OS DNS Cache in High Sierra and newer.
To flush the DNS Cache on Yosemite (OSX 10.10) from terminal:
sudo discoveryutil udnsflushcaches
For even older Mac OS X, Snow Leopard (10.6) and Leopard (10.5), run this command in Terminal:
sudo dscacheutil -flushcache
I have found that despite clearing the DNS cache, Safari may still hold on to old records, so I usually have to quit Safari before clearing the DNS cache, or use another browser like Chrome which is not holding on to old DNS information.
network-tools.com is a useful site for testing DNS resolution from the internet, taking your machine and its DNS cache out of the equation.