mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
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
This commit is contained in:
parent
82f142d376
commit
c94ac152ea
1 changed files with 9 additions and 0 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue