diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-06-27 14:49:12 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-06-27 14:49:12 +0900 |
| commit | f93822cebf6258c3a31e03745183aa2c8bb56f4d (patch) | |
| tree | 8edfba7593d7db039b117fc4d742fbde78b72da6 /src/ollama_web/app.py | |
| parent | b7943a7586fbd0bb0e19aad7732c11a62f72d7c1 (diff) | |
マルチ言語対応。MCP設定画面の言語切り替え表示にバグあり
Diffstat (limited to 'src/ollama_web/app.py')
| -rw-r--r-- | src/ollama_web/app.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ollama_web/app.py b/src/ollama_web/app.py index d0b85d4..c7477c8 100644 --- a/src/ollama_web/app.py +++ b/src/ollama_web/app.py @@ -4,10 +4,13 @@ from __future__ import annotations import logging from pathlib import Path +from typing import Any from starlette.applications import Starlette from starlette.middleware import Middleware from starlette.middleware.cors import CORSMiddleware +from starlette.requests import Request +from starlette.responses import Response from starlette.routing import Mount, Route from starlette.staticfiles import StaticFiles @@ -22,6 +25,19 @@ from .routes import pages as pages_route from .routes import sessions as sessions_route from .sessions import SessionStore + +class NoCacheStaticFiles(StaticFiles): + """StaticFiles variant that disables browser caching for local development. + + This ensures language changes and JS updates are reflected immediately after + a server restart, without requiring users to clear the browser cache. + """ + + async def get_response(self, path: str, scope: Any) -> Response: + response = await super().get_response(path, scope) + response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" + return response + _STATIC_DIR = Path(__file__).resolve().parent / "static" @@ -97,7 +113,7 @@ def create_app() -> Starlette: methods=["PUT"], name="mcp_servers_update", ), - Mount("/static", app=StaticFiles(directory=str(_STATIC_DIR)), name="static"), + Mount("/static", app=NoCacheStaticFiles(directory=str(_STATIC_DIR)), name="static"), ] middleware = [Middleware(SecurityHeadersMiddleware), Middleware(AuthMiddleware)] |
