feat(cache): 开启缓存默认仅缓存标准静态资源

路由缓存策略新增 static(内置扩展名,不含 HTML)与 all;
存量 url 规范为 all。OpenResty 渲染与代理路由 UI 同步。
This commit is contained in:
ryan
2026-07-18 23:32:49 +08:00
parent 7401f5d0b4
commit 04f029c705
11 changed files with 201 additions and 29 deletions
@@ -278,10 +278,10 @@ export function normalizeLimitRate(value: string) {
}
export function validateCacheRules(
policy: 'url' | 'suffix' | 'path_prefix' | 'path_exact',
policy: 'static' | 'all' | 'url' | 'suffix' | 'path_prefix' | 'path_exact',
rules: string[],
) {
if (policy === 'url') {
if (policy === 'static' || policy === 'all' || policy === 'url') {
return null;
}
@@ -335,7 +335,12 @@ 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 || 'url',
cache_policy:
!route.cache_policy || route.cache_policy === 'url'
? route.cache_policy === 'url'
? 'all'
: 'static'
: route.cache_policy,
cache_rules: route.cache_rule_list ?? [],
custom_headers: route.custom_header_list ?? [],
basic_auth_enabled: route.basic_auth_enabled,
@@ -229,7 +229,7 @@ export function ProxyRouteCreateSheet({
limit_conn_per_ip: 0,
limit_rate: '',
cache_enabled: false,
cache_policy: 'url',
cache_policy: 'static',
cache_rules: [],
custom_headers: [],
basic_auth_enabled: false,