AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

Optimistic caching working principle

Open macrocodea opened this issue 2 years ago • 6 comments

Prerequisites

  • [X] I have checked the Wiki and Discussions and found no answer

  • [X] I have searched other issues and found no duplicates

  • [X] I want to request a feature or enhancement and not ask a question

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.

macrocodea avatar Jul 12 '24 13:07 macrocodea

What don't you understand?

Dynamic5912 avatar Jul 12 '24 18:07 Dynamic5912

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?

macrocodea avatar Jul 13 '24 04:07 macrocodea

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?

Dynamic5912 avatar Jul 14 '24 17:07 Dynamic5912

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.

ainar-g avatar Jul 15 '24 12:07 ainar-g

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.

So what will happen when the expired result from cache is incorrect? Like the IP of a domain has changed?

I think the possibility is low since the result with small TTL will not likely change their IP frequently. But just in case, so I’m asking.

quyleanh avatar Apr 02 '25 19:04 quyleanh

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.

So what will happen when the expired result from cache is incorrect? Like the IP of a domain has changed?

I think the possibility is low since the result with small TTL will not likely change their IP frequently. But just in case, so I’m asking.

It will get served to clients whilst updating in the background so you get the correct later once updated

Dynamic5912 avatar Apr 02 '25 21:04 Dynamic5912