I've read that
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache should flush the DNS cache on OSX (macOS Mojave).
However, this command kills processes without restarting them, and is both hard to remember and cumbersome. Also, AFAIK
dscacheutil applies only to the directory service.
Doesn't OSX provide a command like Windows'
ipconfig /flushdns to flush the system's DNS cache?