From f93822cebf6258c3a31e03745183aa2c8bb56f4d Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sat, 27 Jun 2026 14:49:12 +0900 Subject: マルチ言語対応。MCP設定画面の言語切り替え表示にバグあり MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ollama_web/app.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/ollama_web/app.py') 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)] -- cgit v1.2.3