From 32801b5d577071d1c4ea76936734de08abe562c1 Mon Sep 17 00:00:00 2001 From: OoO Date: Mon, 18 May 2026 00:03:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=95=9F=E7=94=A8=E9=9D=9C=E6=85=8B?= =?UTF-8?q?=E8=B3=87=E6=BA=90=E7=89=88=E6=9C=AC=E5=BF=AB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 10 ++++++++++ config.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 4c08258..8bdec26 100644 --- a/app.py +++ b/app.py @@ -136,6 +136,14 @@ if not os.path.exists(os.path.join(TEMPLATE_DIR, 'dashboard_v2.html')): app = Flask(__name__, template_folder=TEMPLATE_DIR, static_folder=STATIC_DIR) +app.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(days=7) + + +@app.url_defaults +def add_static_asset_version(endpoint, values): + """讓靜態資源 URL 跟著系統版本破快取,搭配長快取標頭使用。""" + if endpoint == 'static' and values.get('filename') and 'v' not in values: + values['v'] = SYSTEM_VERSION # ========================================== # 🔒 Flask 安全配置 @@ -615,6 +623,8 @@ def refresh_session(): 在每次請求時自動刷新 Session,避免長時間閒置後突然斷線 只要用戶有任何操作,Session 就會自動延長 """ + if request.endpoint == 'static': + return if session.get('logged_in'): session.modified = True # 標記 Session 已修改,觸發 Cookie 更新 diff --git a/config.py b/config.py index b37543e..c8ad7ee 100644 --- a/config.py +++ b/config.py @@ -320,7 +320,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.161" +SYSTEM_VERSION = "V10.162" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示