action: update git action, patch files.

This commit is contained in:
Nick Peng
2023-03-11 22:06:03 +08:00
parent 8bf1108503
commit 69fd23d756
6 changed files with 84 additions and 76 deletions

View File

@@ -46,58 +46,56 @@ smartdns过期缓存处理流程
%%{init: {'theme':'forest'}}%%
sequenceDiagram
autonumber
participant client as 客户端
participant smartdns as SmartDNS
participant Server as 上游DNS服务器
client->>smartdns: DNS查询
alt 域名在缓存中
smartdns->>+Server: 上游查询DNS
Server-->>-smartdns: 返回查询结果
smartdns->smartdns: 测速,并缓存结果
smartdns->client: 返回结果
else 域名在过期缓存中
rect rgb(160, 250, 140)
smartdns->smartdns: 域名在缓存中,且已经过期。
smartdns->client: 返回结果过期的域名结果TTL为3
smartdns->>+Server: 上游查询DNS
Server->-smartdns: 返回查询结果
smartdns->smartdns: 测速,并缓存结果
client->smartdns: 3s后客户端再次查询获取最佳结果。
end
end
smartdns->>smartdns: 域名在缓存中,且已经过期。
smartdns->>client: 返回结果过期的域名结果TTL为3
smartdns->>+Server: 上游查询DNS
Server->>-smartdns: 返回查询结果
smartdns->>smartdns: 测速,并缓存结果
client->>smartdns: 3s后客户端再次查询获取最佳结果。
```
通过上述序列图可以看到当缓存过期时smartdns仍然将过期的IP地址发给客户端这样客户端就能很快的进行连接服务器这种机制的前提是服务器IP地址没有变化。
现实中大部分情况下修改域名IP地址后是不会立即生效到千家万户的因为一般IP变化域名后全球域名系统刷新完成最长可能要72小时。
即时出现过期缓存中的IP地址故障失效smartdns返回给客户端过期IP的TTL只有3s那么3s后客户端就会重新使用新的IP表现在客户端程序中可能就是要刷新页面重试一次。
并且针对实现场景smartdns可以设置预获取来尽量避免此问题发生。
所以,主要场景下开启过期缓存是比较好的实践。
## 配置步骤
1. 开启过期缓存
```shell
serve-expired yes
```
```shell
serve-expired yes
```
1. 配置过期缓存超时时间
此时间表示过期缓存多长时间未访问,则从缓存中释放。
此时间表示过期缓存多长时间未访问,则从缓存中释放。
```shell
serve-expired-ttl 259200
```
```shell
serve-expired-ttl 259200
```
1. 配置过期缓存响应TTL
此时间表示当缓存中域名TTL超时时返回给客户端的TTL时间让客户端在下列TTL时间后再次查询。
此时间表示当缓存中域名TTL超时时返回给客户端的TTL时间让客户端在下列TTL时间后再次查询。
```shell
serve-expired-reply-ttl 3
```
```shell
serve-expired-reply-ttl 3
```
1. 过期缓存预获取时间
此时间表示过期缓存在多长时间未访问主动进行预先获取以避免IP无效开启过期缓存后prefetch的功能将和未开启不同。
此时间表示过期缓存在多长时间未访问主动进行预先获取以避免IP无效开启过期缓存后prefetch的功能将和未开启不同。
```shell
prefetch-domain yes
serve-expired-prefetch-time 21600
```
```shell
prefetch-domain yes
serve-expired-prefetch-time 21600
```