With this configuration: $ fgrep hosts /etc/nsswitch.conf /etc/nscd.conf /etc/nsswitch.conf:hosts: cache files dns /etc/nscd.conf:enable-cache hosts yes /etc/nscd.conf:positive-time-to-live hosts 60 /etc/nscd.conf:positive-policy hosts lfu /etc/nscd.conf:negative-time-to-live hosts 60 /etc/nscd.conf:negative-policy hosts lfu /etc/nscd.conf:negative-confidence-threshold hosts 3 nscd does not seem to cache DNS answers. Testing with getaddrinfo(1), every query hits the wire, bound for the resolver defined in /etc/resolv.conf. I can't tell if this is a bug, or if I've misconfigured something. (Yes, nscd is enabled in rc.conf and running).
https://svnweb.freebsd.org/base?view=revision&revision=364199 https://forums.freebsd.org/threads/nscd-and-nsswitch-doesnt-seem-to-be-working-together.74789/ It seems to be fixed in 12.2, but also seems to be removed in 13-CURRENT, so you might want to look at migrating to another solution.
(In reply to Conrad Meyer from comment #1) Is there another solution? The requirement is to have the OS stub resolver cache DNS answers system wide. I don't know how to do that without nsswitch/nscd. Shouldn't nsswitch/nscd be fixed?