fix(cache): 存量空/url 策略规范为 all,避免静默收窄

评审修复:enabled 且 policy 为空或 url 时,写入/展示/快照/渲染均映射为 all,
保证旧站点宽缓存范围不变;新建 UI 仍显式提交 static 作为推荐默认。
This commit is contained in:
ryan
2026-07-19 00:02:52 +08:00
parent 04f029c705
commit 204f6d9a8b
11 changed files with 113 additions and 38 deletions
@@ -335,12 +335,17 @@ export function buildPayloadFromRoute(
limit_conn_per_ip: route.limit_conn_per_ip,
limit_rate: route.limit_rate,
cache_enabled: route.cache_enabled,
cache_policy:
!route.cache_policy || route.cache_policy === 'url'
? route.cache_policy === 'url'
? 'all'
: 'static'
: route.cache_policy,
cache_policy: (() => {
if (!route.cache_enabled) {
return 'static';
}
const policy = (route.cache_policy || '').trim();
// Legacy empty/url → all (same as backend displayCachePolicy).
if (!policy || policy === 'url' || policy === 'all') {
return 'all';
}
return policy;
})(),
cache_rules: route.cache_rule_list ?? [],
custom_headers: route.custom_header_list ?? [],
basic_auth_enabled: route.basic_auth_enabled,