AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home.html
GNU General Public License v3.0
24.45k stars 1.77k forks source link

Optimistic caching working principle #7131

Closed macrocodea closed 1 month ago

macrocodea commented 1 month ago

Prerequisites

The problem

"I've searched through several articles but I'm still unclear about how AdGuard Home's optimistic cache functions. With optimistic caching enabled, entries are not updated even after the TTL expires, as long as the IP remains accessible. This poses a significant issue for users relying on the fastest IP address, as we always aim to obtain and locally cache as many recent IP addresses as possible, while ensuring they are kept updated."

Proposed solution

The optimistic cache of AdGuard Home returns the previous result to the client first. However, once the TTL expires, it ensures that the cache is refreshed every time.

Alternatives considered and additional information

Under this setting, frequently requested DNS entries trigger automatic updates whenever their TTL expires.

Dynamic5912 commented 1 month ago

What don't you understand?

macrocodea commented 1 month ago

What don't you understand?

How does its cache update—based on the TTL time I set? Does it refresh every time the cache expires, or is there a chance it refreshes as long as the IP can still connect?

Dynamic5912 commented 1 month ago

What don't you understand?

How does its cache update—based on the TTL time I set? Does it refresh every time the cache expires, or is there a chance it refreshes as long as the IP can still connect?

It's in the documentation?

ainar-g commented 1 month ago

Please send questions to the Discussions, as is recommended in the checkbox that you've checked while filing this issue as well as in the contribution guidelines.

If this is a feature request, I do not understand what you're asking for, so please rephrase that. Currently, optimistic mode just makes the cache return expired results with a small TTL while also triggering a refresh.