dns-over-https
dns-over-https copied to clipboard
Feature: cache
This is the caching feature that I developed some time and have been using for a while now; it has to be considered experimental.
Please review the code looking for bugs/wrong assumptions or something to improve.
I have some suggestions about caching: (The complexity of caching is also the reason why I haven't implement cache)
- EDNS-Subnet shouldn't be stripped, the user's IP address masked with the
scopefield in the response should be used as a part of the cache key. This is to help deliver location-relevant results. - Before the request has yet received a response, the user's IP address masked with the
maskfield in the request can be used as the key to mark an in-flight or failed request. - The cache can also help deduplicate incoming requests -- same requests sent from similar IP addresses are grouped together. Only one sequence of requests is forwarded to upstream, effectively preventing retransmission storm.
- The internal of this software is done on the JSON level, since the software is originally designed for Google JSON protocol, before IETF DoH was a thing. Therefore, it might be easier to do caching at JSON level: I have already parsed those binary into human-readable thing and converted TTL to absolute time. Also this awesome new feature will automatically be compatible with both protocols.