Cache-busting des assets statiques
Le navigateur servait un CSS périmé après mise à jour (aucun invalidateur sur /static). Les liens CSS/JS portent désormais ?v=<mtime des fichiers statiques> : toute modification du design est visible immédiatement chez tous les clients, sans hard-refresh ni bump manuel de version.
This commit is contained in:
@@ -12,6 +12,13 @@ protected = APIRouter(tags=["pages"], include_in_schema=False, dependencies=[Dep
|
|||||||
|
|
||||||
templates = Jinja2Templates(directory=BASE_DIR / "app" / "templates")
|
templates = Jinja2Templates(directory=BASE_DIR / "app" / "templates")
|
||||||
|
|
||||||
|
# Cache-busting des assets : version dérivée de la date des fichiers statiques —
|
||||||
|
# tout changement de CSS/JS invalide le cache navigateur sans intervention.
|
||||||
|
_static_root = BASE_DIR / "app" / "static"
|
||||||
|
templates.env.globals["asset_v"] = str(
|
||||||
|
max(int(p.stat().st_mtime) for p in _static_root.rglob("*") if p.is_file())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/login", response_class=HTMLResponse)
|
@router.get("/login", response_class=HTMLResponse)
|
||||||
async def login_page(request: Request) -> HTMLResponse:
|
async def login_page(request: Request) -> HTMLResponse:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{% block title %}Ohm Stream{% endblock %}</title>
|
<title>{% block title %}Ohm Stream{% endblock %}</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ asset_v }}">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||||
@@ -37,8 +37,8 @@
|
|||||||
<main class="main">
|
<main class="main">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</main>
|
</main>
|
||||||
<script src="/static/js/app.js"></script>
|
<script src="/static/js/app.js?v={{ asset_v }}"></script>
|
||||||
<script src="/static/js/update-watcher.js"></script>
|
<script src="/static/js/update-watcher.js?v={{ asset_v }}"></script>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Connexion — Ohm Stream</title>
|
<title>Connexion — Ohm Stream</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ asset_v }}">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.1/dist/cdn.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.1/dist/cdn.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user