Compare commits

..
1 Commits
Author SHA1 Message Date
hz4th_coder 4f1b7c341c 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禁用缓存走实时
2026-09-11 23:00:03 +08:00
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
+20 -4
View File
@@ -627,8 +627,10 @@
🔄 强制刷新(绕过网址缓存,重新提取)
</label>
</div>
<small style="color: #666; display: block; margin-top: 4px;">
📦 网址缓存<span id="cacheStateBadge"></span>有效期 <span id="cacheTtlBadge"></span>),同网址命中缓存直接返回历史结果,不会重复提取。
<small style="color: #666; display: block; margin-top: 6px; line-height: 1.8;">
📦 网址缓存<span id="cacheStateBadge"></span> 有效期 <span id="cacheTtlBadge"></span>
<button type="button" class="btn-small" onclick="openCaptureCfg()" style="margin-left:8px;padding:3px 10px;font-size:12px;vertical-align:middle;" title="打开缓存/重试设置">⚙️ 设置时效与开关</button><br>
<span style="color:#999;">同网址命中缓存直接返回历史结果,不重复提取;勾选上方「强制刷新」可绕过。</span>
</small>
</div>
@@ -761,7 +763,6 @@
{
"url": "https://example.com",
"action": "smart", // "screenshot" | "html" | "text" | "smart"
"refresh": false, // 可选:true=强制实时提取(绕过网址缓存)
"wait_time": 15000, // 重要!验证网站需设置较长等待
"scroll_times": 3, // 可选:加载动态内容
"scroll_delay": 1000, // 可选:滚动间隔
@@ -770,6 +771,10 @@
"caller": "news-tracker", // 可选:调用者标识(历史记录里显示,默认游客)
"call_method": "api", // 可选:调用方式 web/api(缺省自动判定)
"viewport": {"width":1280,"height":700},
// ---- 📦 网址缓存(默认开启,全局配置在 /api/capture/settings----
"refresh": false, // 可选:true=强制实时提取(绕过缓存)
"cache": true, // 可选:false=本次请求禁用缓存
"cache_ttl_seconds": 3600, // 可选:本次缓存时效(秒),覆盖全局有效期,命中判定也用它
"smart_config": { // 可选:临时覆盖按需截图配置(接口列表按顺序=优先级,失败自动降级)
"endpoints": [
{"name":"本地Qwen", "base_url":"http://121.40.164.32:18008/v1", "api_key":"xxxx", "model":"unsloth/Qwen3.8-27B-NVFP4", "enabled":true},
@@ -779,11 +784,22 @@
"scroll_ratio": 0.85
}
}
// 缓存命中响应(text/html/smart 为 JSONscreenshot 直接返回历史图片文件):
// {success:true, from_cache:true, history_id:123, cached_at:"2026-09-11 22:49:41", cache_ttl_seconds:3600, ...}
📦 缓存/🔁 重试全局配置(页面「⚙️ 缓存/重试」按钮或以下接口):
GET /api/capture/settings
POST /api/capture/settings
{
"settings": {
"cache": {"enabled": true, "ttl_seconds": 3600}, // enabled=缓存开关, ttl_seconds=有效期(秒)
"retry": {"max_retries": 2, "delay_seconds": 2} // max_retries=失败重试次数(默认2), delay_seconds=重试间隔(秒)
}
}
GET /api/smart/config // 获取智能截图配置(含 endpoints 多接口列表)
POST /api/smart/config // 保存配置(body: {config:{endpoints:[...], prompt, max_scrolls,...}}
POST /api/smart/test // 测试指定接口(body: {endpoint_id} 或 {endpoint:{...}} 或旧版 {config:{...}}
GET /api/capture/settings // 网址缓存+失败重试 配置({cache:{enabled,ttl_seconds}, retry:{max_retries,delay_seconds}}
GET /api/history?page=1&page_size=15&action=all&search=关键词 // 历史分页
GET /api/history/stats?dimension=day&days=30 // 历史统计(dimension: day/action/backend/status/caller/method
GET /api/history/&lt;id&gt; // 历史详情