Confused by dnsmasq stats

I'm confused by my dnsmasq stats (retrieved from logread after kill -USR1).
I use an external DNS service.
The number of forwarded queries is given as 149165, but the number of queries sent to the upstream DNS server is only 11256. I would think they would be the same or very similar. What am I not understanding?
Thanks!

Thu Sep 15 18:09:30 2022 daemon.info dnsmasq[4293]: queries forwarded 149165, queries answered locally 169647
Thu Sep 15 18:09:30 2022 daemon.info dnsmasq[4293]: server x.x.x.x#53: queries sent 11256, retried or failed 712
Thu Sep 15 18:09:30 2022 daemon.info dnsmasq[4293]: server x.x.x.x#53: queries sent 712, retried or failed 0

Isn't it 11256 + 712, or even +712 again ?

The difference is probably due to caching.

I have 2 external DNS servers configured. 712 queries were sent to server 2 after server 1 failed or timed out.

I think "answered locally" is from the cache. "forwarded" sounds like sent to the server, not answered from the cache.

You can double check to see if DNSMasq is actually caching by doing a DNS lookup on a site that wouldn't be cached:

dig amishbaskets.com

and look at the query time which is the time from your DNS resolver.

Do it again and the query time should be 0 or almost 0 if it's from the cache.

I think I figured this out. My WAN connection dropped and OpenWRT re-established the connection. A while later the dnsmasq stats show as follows:

Tue Sep 20 13:09:45 2022 daemon.notice netifd: Interface 'wan' is now up
Tue Sep 20 13:09:45 2022 daemon.info dnsmasq[4293]: reading /tmp/resolv.conf.d/resolv.conf.auto
...
Wed Sep 21 08:19:09 2022 daemon.info dnsmasq[4293]: queries forwarded 171049, queries answered locally 229164
Wed Sep 21 08:19:09 2022 daemon.info dnsmasq[4293]: server x.x.x.x#53: queries sent 3631, retried or failed 491
Wed Sep 21 08:19:09 2022 daemon.info dnsmasq[4293]: server x.x.x.x#53: queries sent 491, retried or failed 0
r

So the queries forwarded number refers to the total number of queries that the dnsmasq process sent upstream since it started. You can see that it continued incrementing since my first post (the router did not reboot in the meantime).

The queries sent to each server is the number of queries sent to that server in the current session, i.e. since the last time it last reconfigured (i.e. it read resolv.conf.auto etc.).