Unless you're using DNS over HTTP (DoH), you can speed up general DNS requests by running a local DNS proxy, and increase the expiry time of DNS queries. I'll go into this further once I've updated this post for DNSMASQ to do DoH.
The following configuration will speed up browsing in Safari for example.
brew install dnsmasq
Load all configs from /etc/local/etc/dnsmasq.d/:
echo "conf-dir=/usr/local/etc/dnsmasq.d,*.conf" | sudo tee —append /usr/local/etc/dnsmasq.conf
mkdir -p /usr/local/etc/dnsmasq.d
# Tell dnsmasq to get its DNS servers from this config file only.
# Add router dns
# cache for 2h
min-cache-ttl = 7200
Start DNSMASQ on boot and launch it:
sudo brew services start dnsmasq
dig cnn.com @127.0.0.1
Query time should be 0 the second time and an ANSWER SECTION should be returned. If that is the case open System Preferences > Network > Advanced > DNS > +
Enter: 127.0.0.1 and hit OK > Apply.