Skip to content

如何精细控制缓存 #1999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Arrow-Li opened this issue May 13, 2025 · 15 comments
Open

如何精细控制缓存 #1999

Arrow-Li opened this issue May 13, 2025 · 15 comments

Comments

@Arrow-Li
Copy link

需求应用场景

  • 指定dns server返回的结果不缓存
  • 返回的指定ip不缓存,(fakeip情况下很需要,类似 198.18.0.0/16 -no-cache)

建议的方案
研究了下文档没发现如何实现,现在是否已经能支持,还是不行?

@PikuZheng
Copy link
Contributor

domain-rules 可以指定 -no-cache (需要41.0.16或更高版本

指定上游的结果不缓存,逻辑上有点难。因为上游是并发查询的,缓存是多个上游结果的合并

@Arrow-Li
Copy link
Author

domain-rules只能指定域名吧,fakeip是基于ip段的规则

@Arrow-Li
Copy link
Author

我的配置,现在默认是返回fakeip,domain-rules是针对cn的情况,如果全局关闭缓存,cn部分就没办法开缓存了
domain-rules好像没有一个开缓存的选项,-enable-cache

@PikuZheng
Copy link
Contributor

PikuZheng commented May 13, 2025

昂。我理解错了。你是需要指定的ip不写入缓存。
domain-rules 的 -enable-cache 需要v43.0.76或更高版本

@CallMeR
Copy link

CallMeR commented May 13, 2025

Fake IP 虽然分流变简单了,但是缓存却便复杂了

@SoulOS1992
Copy link

昂。我理解错了。你是需要指定的ip不写入缓存。 domain-rules 的 -enable-cache 需要v43.0.76或更高版本

支持CIDR?

@PikuZheng
Copy link
Contributor

昂。我理解错了。你是需要指定的ip不写入缓存。 domain-rules 的 -enable-cache 需要v43.0.76或更高版本

支持CIDR?

domain-rule是基于域名的,和查询结果的ip无关

@SoulOS1992
Copy link

昂。我理解错了。你是需要指定的ip不写入缓存。 domain-rules 的 -enable-cache 需要v43.0.76或更高版本

支持CIDR?

domain-rule是基于域名的,和查询结果的ip无关

好的,谢谢,请问有设计与添加 有CIDR范围不写入缓存 功能的打算吗?

@PikuZheng
Copy link
Contributor

我翻了一下 #1236 ,好像你是第一个提出 server 或 ip-rules 需要支持 no-cache 的。

但我想知道,在你的使用环境中,谁负责根据域名分流(也就是说谁给出fake-ip的结果)?
另一方面fake-ip对应的域名大多为正常上网的流量,如果不缓存的话,可能会导致内网大量反复查询?可以参考 mihomo(ClashMeta)的issue,他们强烈建议不要这么干

@Arrow-Li
Copy link
Author

我翻了一下 #1236 ,好像你是第一个提出 server 或 ip-rules 需要支持 no-cache 的。

但我想知道,在你的使用环境中,谁负责根据域名分流(也就是说谁给出fake-ip的结果)? 另一方面fake-ip对应的域名大多为正常上网的流量,如果不缓存的话,可能会导致内网大量反复查询?可以参考 mihomo(ClashMeta)的issue,他们强烈建议不要这么干

geo:cn都直接在smartdns里闭环查询,只有非cn才会走到xray的dns去fakeip查询

@PikuZheng
Copy link
Contributor

根据 Project X 的文档,xray返回的 fake-ip的ttl=1,即使缓存也是一秒过期。那没必要再折腾smartdns啊

@Arrow-Li
Copy link
Author

根据 Project X 的文档,xray返回的 fake-ip的ttl=1,即使缓存也是一秒过期。那没必要再折腾smartdns啊

实际上smartdns里存的是600,smartdns --cache-print

@PikuZheng
Copy link
Contributor

那你有没有确认xray返回的ttl是多少。。。如果是1,需要修改smartdns rr-ttl-min 1

@CallMeR
Copy link

CallMeR commented May 27, 2025

借 issue 问个也和缓存相关的问题,如果 smartdns 监听了两个端口,分别处理 cn 和 ncn 的域名请求,且都开启了缓存,那么在 serve-expired yes 和 prefetch-domain yes 的情况下,域名预取时会根据原查询端口进行预取还是直接使用 default nameserver 进行查询呢?

@PikuZheng
Copy link
Contributor

借 issue 问个也和缓存相关的问题,如果 smartdns 监听了两个端口,分别处理 cn 和 ncn 的域名请求,且都开启了缓存,那么在 serve-expired yes 和 prefetch-domain yes 的情况下,域名预取时会根据原查询端口进行预取还是直接使用 default nameserver 进行查询呢?

就我所知cache是以不同的group分别做cache。prefetch会遵循在cache时记录的组(如果启用了持久缓存,可能会导致重启后组配置变化了,但仍走原来的组

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants