diff --git a/app/sovran_systemsos_web/server.py b/app/sovran_systemsos_web/server.py index 6ec1a8d..176f301 100644 --- a/app/sovran_systemsos_web/server.py +++ b/app/sovran_systemsos_web/server.py @@ -23,6 +23,7 @@ from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates from fastapi.requests import Request from pydantic import BaseModel +from starlette.middleware.base import BaseHTTPMiddleware from .config import load_config from . import systemctl as sysctl @@ -428,6 +429,19 @@ _BASE_DIR = os.path.dirname(os.path.abspath(__file__)) app = FastAPI(title="Sovran_SystemsOS Hub") + +class NoCacheMiddleware(BaseHTTPMiddleware): + async def dispatch(self, request, call_next): + response = await call_next(request) + response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" + response.headers["Pragma"] = "no-cache" + response.headers["Expires"] = "0" + response.headers["Clear-Site-Data"] = '"cache", "cookies", "storage"' + return response + + +app.add_middleware(NoCacheMiddleware) + _ICONS_DIR = os.environ.get( "SOVRAN_HUB_ICONS", os.path.join(os.path.dirname(_BASE_DIR), "icons"), diff --git a/modules/core/caddy.nix b/modules/core/caddy.nix index e51a599..d97ede7 100755 --- a/modules/core/caddy.nix +++ b/modules/core/caddy.nix @@ -162,6 +162,12 @@ EOF http://sovransystemsos.local { reverse_proxy localhost:8937 + header { + Clear-Site-Data "\"cache\", \"cookies\", \"storage\"" + Cache-Control "no-store, no-cache, must-revalidate, max-age=0" + Pragma "no-cache" + Expires "0" + } } EOF