From a7d3af4ddd9e9680aff3999c70a1d1f91514bf44 Mon Sep 17 00:00:00 2001 From: naturallaw77 Date: Thu, 2 Apr 2026 14:50:07 -0500 Subject: [PATCH] fixed cache --- app/sovran_systemsos_web/server.py | 23 +++++++++++++++++-- app/sovran_systemsos_web/templates/index.html | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/sovran_systemsos_web/server.py b/app/sovran_systemsos_web/server.py index 2034a0f..8233497 100644 --- a/app/sovran_systemsos_web/server.py +++ b/app/sovran_systemsos_web/server.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio +import hashlib import json import os import re @@ -71,6 +72,20 @@ if os.path.isdir(_ICONS_DIR): 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 ───────────────────────────────────────── def _get_locked_info(): @@ -230,11 +245,15 @@ def _resolve_credential(cred: dict) -> dict | None: return {"label": label, "value": value, "multiline": multiline} -# ── Routes ─────────────────────────────────────────────────────── +# ── Routes ───────────��─────────────────────────────────────────── @app.get("/", response_class=HTMLResponse) 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") diff --git a/app/sovran_systemsos_web/templates/index.html b/app/sovran_systemsos_web/templates/index.html index e7f0f7e..94970ed 100644 --- a/app/sovran_systemsos_web/templates/index.html +++ b/app/sovran_systemsos_web/templates/index.html @@ -4,7 +4,7 @@ Sovran_SystemsOS Hub - + @@ -85,6 +85,6 @@ - + \ No newline at end of file