Created attachment 535[details]
My unbound conf file
I turn on 'stub-no-cache' and 'forward-no-cache' in my conf file. But Unbound still cache the records. So I wonder how can I disable caching for stub zones and forward-zones?

Hi Tao Dong,
Is this caused by the edns-client-subnet module? It does not happen for me, when I set the option no-cache works as it should. But I see edns-client-subnet options in the config you send, even though the edns-client-subnet does not seem enabled in that config. The edns-client-subnet implementation has its own cache, which is not impacted by the no-cache options.
Best regards, Wouter

(In reply to Wouter Wijngaards from comment #1)
> Hi Tao Dong,
>
> Is this caused by the edns-client-subnet module? It does not happen for me,
> when I set the option no-cache works as it should. But I see
> edns-client-subnet options in the config you send, even though the
> edns-client-subnet does not seem enabled in that config. The
> edns-client-subnet implementation has its own cache, which is not impacted
> by the no-cache options.
>
> Best regards, Wouter
Thanks a lot! I think you are right. When I compile unbnound without '--enable-subnet', the options 'stub-no-cache' and 'forward-no-cache' work fine.However when compling with '--enable-subnet', the options do not work.

Hi Tao Dong,
Thanks for the report and test without edns-subnet, I fixed the issue, and the no_cache option should work when you compile unbound with edns-subnet enabled. The edns-subnet was using the flag itself to modify if the global cache was modified or the subnet cache, and this reset the value back to false, causing messages to get stored in cache.
Best regards, Wouter