refactor: split large modules and harden live-room fudai flow

This commit is contained in:
Your Name committed 2026-06-01 18:39:44 +08:00
1 parent 1845561405
commit 36e374ef67
86 files changed
+7422 -8404

No files matched your search

+9 -6
View File
@@ -50,23 +50,26 @@ def serve_static(
data = f.read()
# 对于静态资源,使用适当的缓存策略
cache_control = "no-store" if ext in (".html", ".js") else "public, max-age=3600"
handler.send_response(HTTPStatus.OK)
handler.send_header("Content-Type", ctype)
handler.send_header("Content-Length", str(len(data)))
handler.send_header("Cache-Control", cache_control)
# 添加 ETag 支持(简单实现:基于文件大小和修改时间)
try:
stat = os.stat(full)
etag = f'"{stat.st_size}-{int(stat.st_mtime)}"'
handler.send_header("ETag", etag)
# 检查 If-None-Match 头,支持 304 Not Modified
if_none_match = handler.headers.get("If-None-Match", "")
if if_none_match == etag:
handler.send_response(HTTPStatus.NOT_MODIFIED)
handler.send_header("ETag", etag)
handler.send_header("Cache-Control", cache_control)
handler.end_headers()
return
except Exception:
pass
etag = None
handler.send_response(HTTPStatus.OK)
handler.send_header("Content-Type", ctype)
handler.send_header("Content-Length", str(len(data)))
handler.send_header("Cache-Control", cache_control)
if etag:
handler.send_header("ETag", etag)
handler.end_headers()
handler.wfile.write(data)
except FileNotFoundError: