diff --git a/CHANGELOG.md b/CHANGELOG.md index b322240..cafcfb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Format basé sur [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/), et [Semantic Versioning](https://semver.org/spec/v2.0.0.html). > **En cours de développement** : les changements à venir sont listés dans la section -> [Unreleased](#unreleased). La dernière version livrée est **2.97.0**. +> [Unreleased](#unreleased). La dernière version livrée est **2.98.0**. --- @@ -14,6 +14,18 @@ et [Semantic Versioning](https://semver.org/spec/v2.0.0.html). --- +## [2.98.0] — 2026-11-30 + +### Ajouté + +- **Audit de chargement versionné (#241, épopée perf #240)** : `scripts/audit_chargement.py` (stdlib seule) mesure TTFB/total médians, en-têtes de cache et graphe de modules ES statiques (mode distant ou `--local`) ; budget de chargement figé dans `docs/features/perf-chargement-240.md` (affichage utile ÷3, JS initial −50 %, `/api/dashboard` répété < 50 ms). +- **Bootstrap rapide des liens profonds (#244)** : à l'arrivée sur un lien `#file=` (y compris au retour d'un SSO), le fichier cible s'ouvre dès l'authentification faite, avant le chargement des réglages des vaults, de la liste des vaults et des tags ; le chargement complet suit sans recouvrir la cible. `#folder=` inchangé (il a besoin de l'arborescence chargée). +- **Cache mémoire de `/api/dashboard` (#245)** : résultat mis en cache 60 s par utilisateur et invalidé dès que le watcher signale un changement d'index — les appels répétés ne parcourent plus les 10 987 fichiers à chaque fois. +- **Chargement paresseux des modules lourds et des CDN (#243)** : Mermaid, vue graphe, Excalidraw, now-playing, plugins, push et l'éditeur mobile sont chargés par `import()` dynamique à la première utilisation (ou en tâche de fond) au lieu du graphe statique initial (41 → 34 modules, −12,5 % en octets bruts — le cœur couplé viewer/ui reste statique, voir fiche #240) ; les 13 scripts CDN du `` (Mermaid 745 Ko, highlight.js + 10 langages, Lucide) sont retirés : highlight arrive au premier bloc de code (base + langage détecté), Lucide au premier appel d'icônes, Mermaid au premier diagramme. +- **Cache versionné des statiques (#242)** : les URL `/static/…` de `index.html` et les imports des modules ES sont réécrits au service avec `?v=` (`backend/static_versioning.py`, serveur `VersionedStaticFiles`) ; `Cache-Control: immutable` (1 an) uniquement pour les URL à la version courante, `no-cache` sinon — le cache long ne peut plus servir un build périmé. Le service worker porte un nom de cache à la version courante (ancien cache abandonné à l'activation). La règle Cloudflare « HIT » sur les statiques versionnées reste une action d'exploitation hors code. + +--- + ## [2.97.0] — 2026-11-30 ### Ajouté diff --git a/README.fr.md b/README.fr.md index d375334..3b363cf 100644 --- a/README.fr.md +++ b/README.fr.md @@ -4,7 +4,7 @@ **Porte d'entrée web ultra-léger pour vos vaults Obsidian** — Accédez, naviguez et recherchez dans toutes vos notes Obsidian depuis n'importe quel appareil via une interface web moderne et responsive. -[![Version](https://img.shields.io/badge/Version-2.97.0-blue.svg)]() +[![Version](https://img.shields.io/badge/Version-2.98.0-blue.svg)]() [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://www.docker.com/) [![Python](https://img.shields.io/badge/Python-3.11+-green.svg)](https://www.python.org/) @@ -981,8 +981,8 @@ Ce projet est sous licence **MIT** — voir le fichier [LICENSE](LICENSE) pour l ## 📝 Changelog -Consultez le [CHANGELOG.md](./CHANGELOG.md) pour l'historique complet de toutes les versions (v1.0.0 → v2.97.0). +Consultez le [CHANGELOG.md](./CHANGELOG.md) pour l'historique complet de toutes les versions (v1.0.0 → v2.98.0). --- -*Projet : ObsiGate | Version : 2.97.0 | Dernière mise à jour : Septembre 2026* +*Projet : ObsiGate | Version : 2.98.0 | Dernière mise à jour : Septembre 2026* diff --git a/README.md b/README.md index 756d3d1..1ce6f85 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **Ultra-light web gateway for your Obsidian vaults** — Access, browse, and search all your Obsidian notes from any device via a modern, responsive web interface. -[![Version](https://img.shields.io/badge/Version-2.97.0-blue.svg)]() +[![Version](https://img.shields.io/badge/Version-2.98.0-blue.svg)]() [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://www.docker.com/) [![Python](https://img.shields.io/badge/Python-3.11+-green.svg)](https://www.python.org/) @@ -1156,8 +1156,8 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) ## 📝 Changelog -See [CHANGELOG.md](./CHANGELOG.md) for the complete version history (v1.0.0 → v2.97.0). +See [CHANGELOG.md](./CHANGELOG.md) for the complete version history (v1.0.0 → v2.98.0). --- -*Project: ObsiGate | Version: 2.97.0 | Last updated: September 2026* +*Project: ObsiGate | Version: 2.98.0 | Last updated: September 2026* diff --git a/VERSION b/VERSION index e362c04..7cdfdfa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.97.0 +2.98.0 diff --git a/backend/main.py b/backend/main.py index d2b897a..329abf7 100644 --- a/backend/main.py +++ b/backend/main.py @@ -70,6 +70,11 @@ async def _on_vault_change(events: list): Processes each event (create/modify/delete/move) and updates the index incrementally, then broadcasts SSE notifications. """ + # #245 : tout changement d'index invalide le cache du dashboard. + from backend.routers.config import invalidate_dashboard_cache + + invalidate_dashboard_cache() + updated_vaults = set() changes = [] @@ -245,12 +250,17 @@ class SecurityHeadersMiddleware(BaseHTTPMiddleware): yield patched response.body_iterator = _docs_body() - # Static assets are NOT content-hashed, so they must revalidate: - # ``immutable``/long max-age made Cloudflare and mobile browsers serve - # a stale build for a year (the service worker cache compounded it). - # ``no-cache`` keeps caching but forces revalidation (ETag/Last-Modified). + # Cache des statiques (#242) : ``immutable`` UNIQUEMENT pour les + # URL versionnées ``?v=`` (voir + # backend.static_versioning) — une nouvelle version change toutes + # les URL, donc le piège historique (cache long sans versionnage + # → build périmé servi un an) ne peut pas se reproduire. Sans + # ``?v=`` valide : ``no-cache`` (revalidation ETag/Last-Modified). if request.url.path.startswith("/static/"): - response.headers["Cache-Control"] = "no-cache" + from backend.static_versioning import cache_control_for + + response.headers["Cache-Control"] = cache_control_for( + request.url.path, request.url.query) return response @@ -927,6 +937,10 @@ def _index_html(request: Request) -> str: from backend.draco_config import urls_publiques html = (FRONTEND_DIR / "index.html").read_text(encoding="utf-8") + # #242 : URL statiques versionnées (?v=) — cache long sûr. + from backend.static_versioning import rewrite_static_urls + + html = rewrite_static_urls(html) script = ( " - - - - - - - - - - - - ' \ + 'x' + out = sv.rewrite_static_urls(html, version="9.9.9") + assert "/static/style.css?v=9.9.9" in out + assert "/static/js/app.js?v=9.9.9" in out + assert "example.com/static/nope.css?v=" not in out + + +def test_rewrite_js_imports_adds_version(): + source = ( + "import * as UI from './ui.js';\n" + "import './side.js';\n" + "export { x } from '../shared.js';\n" + "const m = await import('./lazy.js');\n" + "const s = 'pas un import ./faux.js';\n" + ) + out = sv.rewrite_js_imports(source, version="9.9.9") + assert "'./ui.js?v=9.9.9'" in out + assert "'./side.js?v=9.9.9'" in out + assert "'../shared.js?v=9.9.9'" in out + assert "'./lazy.js?v=9.9.9'" in out + + +def test_cache_control_only_immutable_for_current_version(): + current = sv.current_version() + assert sv.cache_control_for("/static/js/app.js", f"v={current}") == sv.IMMUTABLE_CACHE_CONTROL + # Ancienne version / absence de version : jamais de cache long. + assert sv.cache_control_for("/static/js/app.js", "v=0.0.1") == sv.NO_CACHE + assert sv.cache_control_for("/static/js/app.js", "") == sv.NO_CACHE + assert sv.cache_control_for("/api/dashboard", f"v={current}") is None + + +def test_served_headers_and_rewriting(client): + """Via l'application : en-têtes selon ?v= et corps JS réécrit.""" + current = sv.current_version() + + versioned = client.get(f"/static/js/app.js?v={current}") + assert versioned.status_code == 200 + assert "immutable" in versioned.headers.get("cache-control", "") + assert f"?v={current}" in versioned.text # imports réécrits au service + + plain = client.get("/static/js/app.js") + assert plain.status_code == 200 + assert plain.headers.get("cache-control") == "no-cache" + + stale = client.get("/static/js/app.js?v=0.0.1") + assert stale.headers.get("cache-control") == "no-cache" + + index = client.get("/") + assert index.status_code == 200 + assert index.headers.get("cache-control") == "no-cache" + assert f"/static/style.css?v={current}" in index.text + assert f"/static/js/app.js?v={current}" in index.text + + +def test_service_worker_carries_current_version(client): + current = sv.current_version() + sw = client.get("/sw.js") + assert sw.status_code == 200 + assert "__OBSIGATE_SW_VERSION__" not in sw.text + assert f"v{current}" in sw.text