From c94ac152ea99034031b0aa1467c6b77afd117f5b Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 10 Oct 2026 19:15:39 +0200 Subject: [PATCH] fix: browser gets stuck in a reload loop after a server upgrade (#31631) After a server upgrade, browsers could keep reusing their cached copy of the old app page for days, since it was sent with no caching instructions. That old page points at files the new version no longer has, so the app reloads into the same cached page and loops until a hard refresh. The app page now tells the browser to check for a newer version on every visit, which is a tiny request when nothing changed. Other files are cached as before, and an admin-set CACHE_CONTROL still takes precedence. Fixes #31630 --- backend/open_webui/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index feab206fa6..f9b58038b9 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -319,6 +319,15 @@ class SPAStaticFiles(StaticFiles): else: raise ex + def file_response( + self, full_path: str, stat_result: os.stat_result, scope: dict, status_code: int = 200 + ) -> Response: + response = super().file_response(full_path, stat_result, scope, status_code) + if full_path.endswith('.html'): + # Stale cached HTML references chunks from an older build + response.headers['Cache-Control'] = 'no-cache' + return response + class CORSStaticFiles(StaticFiles): async def get_response(self, path: str, scope):