fixed cache
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -71,6 +72,20 @@ if os.path.isdir(_ICONS_DIR):
|
|||||||
|
|
||||||
templates = Jinja2Templates(directory=os.path.join(_BASE_DIR, "templates"))
|
templates = Jinja2Templates(directory=os.path.join(_BASE_DIR, "templates"))
|
||||||
|
|
||||||
|
# ── Static asset cache-busting ────────────────────────────────────
|
||||||
|
|
||||||
|
def _file_hash(filename: str) -> str:
|
||||||
|
"""Return first 8 chars of the MD5 hex digest for a static file."""
|
||||||
|
path = os.path.join(_BASE_DIR, "static", filename)
|
||||||
|
try:
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
return hashlib.md5(f.read()).hexdigest()[:8]
|
||||||
|
except FileNotFoundError:
|
||||||
|
return "0"
|
||||||
|
|
||||||
|
_APP_JS_HASH = _file_hash("app.js")
|
||||||
|
_STYLE_CSS_HASH = _file_hash("style.css")
|
||||||
|
|
||||||
# ── Update check helpers ─────────────────────────────────────────
|
# ── Update check helpers ─────────────────────────────────────────
|
||||||
|
|
||||||
def _get_locked_info():
|
def _get_locked_info():
|
||||||
@@ -230,11 +245,15 @@ def _resolve_credential(cred: dict) -> dict | None:
|
|||||||
return {"label": label, "value": value, "multiline": multiline}
|
return {"label": label, "value": value, "multiline": multiline}
|
||||||
|
|
||||||
|
|
||||||
# ── Routes ───────────────────────────────────────────────────────
|
# ── Routes ───────────<EFBFBD><EFBFBD>───────────────────────────────────────────
|
||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request):
|
async def index(request: Request):
|
||||||
return templates.TemplateResponse("index.html", {"request": request})
|
return templates.TemplateResponse("index.html", {
|
||||||
|
"request": request,
|
||||||
|
"app_js_hash": _APP_JS_HASH,
|
||||||
|
"style_css_hash": _STYLE_CSS_HASH,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/config")
|
@app.get("/api/config")
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Sovran_SystemsOS Hub</title>
|
<title>Sovran_SystemsOS Hub</title>
|
||||||
<link rel="stylesheet" href="/static/style.css?v=4" />
|
<link rel="stylesheet" href="/static/style.css?v={{ style_css_hash }}" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -85,6 +85,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/app.js?v=4"></script>
|
<script src="/static/app.js?v={{ app_js_hash }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user