fix+perf: SQLite连接busy_timeout修复并发锁/静态版本号缓存/删除资产批量清理/安全检查最新记录子查询修正/AI余额与SSL探测并发化/密钥常量时间比较
This commit is contained in:
+13
-5
@@ -35,12 +35,20 @@ def _asset_version() -> str:
|
||||
|
||||
用于前端引用 ?v= 参数,绕开浏览器启发式缓存(旧响应无 Cache-Control
|
||||
时存下的条目会被视为新鲜而不再回源验证)。
|
||||
启动时计算一次并缓存:静态资源只在代码更新时变化,而更新后服务会重启,
|
||||
避免每次页面请求都遍历 stat 整个 static 目录。
|
||||
"""
|
||||
latest = 0
|
||||
for p in STATIC_DIR.rglob("*"):
|
||||
if p.is_file():
|
||||
latest = max(latest, int(p.stat().st_mtime))
|
||||
return str(latest)
|
||||
global _ASSET_VERSION_CACHE
|
||||
if _ASSET_VERSION_CACHE is None:
|
||||
latest = 0
|
||||
for p in STATIC_DIR.rglob("*"):
|
||||
if p.is_file():
|
||||
latest = max(latest, int(p.stat().st_mtime))
|
||||
_ASSET_VERSION_CACHE = str(latest)
|
||||
return _ASSET_VERSION_CACHE
|
||||
|
||||
|
||||
_ASSET_VERSION_CACHE: str | None = None
|
||||
|
||||
# 全局日志配置:统一格式,便于生产环境排查
|
||||
logging.basicConfig(
|
||||
|
||||
Reference in New Issue
Block a user