修复登记借出按钮并更新前端缓存版本
This commit is contained in:
@@ -808,6 +808,16 @@ async def security_headers(request: Request, call_next):
|
||||
)
|
||||
if request.url.path.startswith(("/api/", "/join/", "/duty-confirm/", "/mail-test/")):
|
||||
response.headers["Cache-Control"] = "no-store"
|
||||
elif request.method in ("GET", "HEAD") and (
|
||||
request.url.path == "/"
|
||||
or request.url.path.endswith(".html")
|
||||
or not Path(request.url.path).suffix
|
||||
):
|
||||
# 让入口 HTML 每次重新校验,避免新脚本上线后仍被旧页面长期引用。
|
||||
response.headers["Cache-Control"] = "no-cache"
|
||||
elif request.method in ("GET", "HEAD") and Path(request.url.path).suffix in (".js", ".css"):
|
||||
# 前端资源通过 ?v= 更新版本号;保留 ETag 校验以便紧急修复时立即生效。
|
||||
response.headers["Cache-Control"] = "public, max-age=0, must-revalidate"
|
||||
if request.url.path.startswith(("/join/", "/duty-confirm/", "/mail-test/")):
|
||||
kind = "test" if request.url.path.startswith("/mail-test/") else ("duty" if request.url.path.startswith("/duty-confirm/") else "activity")
|
||||
origin_kind = "none" if not origin else ("null" if origin == "null" else ("trusted" if origin in (own_origin, trusted_origin) else "other"))
|
||||
|
||||
Reference in New Issue
Block a user