v1.9.1 缓存时效设置入口显眼化 + API支持per-request缓存参数 + 页面API说明同步

1) 页面可见性: 高级选项区缓存状态行改为可点击「⚙️ 设置时效与开关」按钮(直接打开设置弹窗), 明确设置入口
2) API per-request 缓存参数:
   - cache_ttl_seconds: 本次请求缓存时效(秒), 覆盖全局有效期, 命中判定也用它
   - cache: false / no_cache: true: 本次请求禁用缓存
   (refresh=true 强制刷新已有)
3) 页面API调用说明段完整同步: refresh/cache/cache_ttl_seconds 参数注释 + POST /api/capture/settings 请求示例 + 缓存命中响应字段说明
验证: cache_ttl_seconds=3600命中历史并回显TTL / =1超期走实时 / cache:false禁用缓存走实时
This commit is contained in:
2026-09-11 23:00:03 +08:00
parent 65259ab5b4
commit 4f1b7c341c
2 changed files with 30 additions and 6 deletions
+10 -2
View File
@@ -1584,6 +1584,8 @@ def capture():
"url": "https://example.com",
"action": "screenshot" | "html" | "text" | "smart",
"refresh": false, // 可选:true=强制实时提取(绕过网址缓存)
"cache": true, // 可选:false=本次请求禁用缓存
"cache_ttl_seconds": 3600, // 可选:本次请求的缓存时效(秒),覆盖全局设置;命中判定也用它
"scroll_times": 0,
"scroll_delay": 1000,
"full_page": false,
@@ -1637,9 +1639,15 @@ def capture():
cache_cfg = settings.get("cache", DEFAULT_CACHE_CONFIG)
retry_cfg = settings.get("retry", DEFAULT_RETRY_CONFIG)
force_refresh = bool(data.get("refresh") or data.get("force"))
# per-request 缓存参数:cache_ttl_seconds=本次缓存时效(覆盖全局)cache=false / no_cache=true=本次禁用缓存
no_cache = data.get("cache") is False or str(data.get("no_cache")).lower() in ("true", "1", "yes")
try:
cache_ttl_override = max(1, int(data.get("cache_ttl_seconds"))) if data.get("cache_ttl_seconds") is not None else None
except Exception:
cache_ttl_override = None
if cache_cfg.get("enabled") and not force_refresh:
ttl = int(cache_cfg.get("ttl_seconds", 3600))
if cache_cfg.get("enabled") and not force_refresh and not no_cache:
ttl = cache_ttl_override or int(cache_cfg.get("ttl_seconds", 3600))
hit = find_cache_hit(url, action, ttl)
if hit:
hit["from_cache"] = True