Stale-while-revalidate for DNS caching #1860
notpushkin
started this conversation in
Ideas
Replies: 0 comments
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Some background:
stale-while-revalidate
is a caching mechanism in HTTP that allows reusing old query result while simultaneiusly refetching a fresh response to use for the next request. For example, with the following header:Cache-Control: max-age=1, stale-while-revalidate=59
If a request is repeated within the next 1 second, the previously cached value will still be fresh, and used as-is, without any revalidation.
If a request is repeated between 1 and 60 seconds later, then the cached value will be stale, but will be used to fulfill the API request. At the same time, "in the background," a revalidation request will be made to populate the cache with a fresh value for future use.
This could work with dnscrypt-proxy as well. E. g. with the following settings:
If a request is repeated within the next 40 minutes, the previously cached value will still be fresh, and used as-is, without any revalidation.
If a request is repeated between 40 minutes and 6 hours, then the cached value will be stale, but will be returned to the client (e. g. browser) with TTL of 1 (so that it doesn't cache it any further). At the same time, "in the background," a revalidation request will be made to populate the cache with a fresh value for future use.
Beta Was this translation helpful? Give feedback.
All reactions