mirror of
https://github.com/zebrajr/ollama-webui.git
synced 2026-01-15 12:15:13 +00:00
fix: user group pagination reset and model image caching (#19959)
- Changed default sort order in 'Edit Group' modal to 'created_at' (newest first). Previously it sorted by group membership, causing toggled users to invisible jump to the top of the list (often changing pages). using a stable sort fixes this UX issue. - Removed unnecessary `page = 1` reset in toggleMember function so admins don't lose their place when selecting multiple users. Bug 2 - Model Image Display Bug: - Added `Cache-Control: no-cache, must-revalidate` headers to the model profile image endpoint. This ensures that when a model avatar is updated, the browser fetches the new image instead of serving a stale cached version (favicon). Fixes #19885
This commit is contained in:
@@ -291,12 +291,15 @@ async def get_model_by_id(id: str, user=Depends(get_verified_user)):
|
||||
@router.get("/model/profile/image")
|
||||
async def get_model_profile_image(id: str, user=Depends(get_verified_user)):
|
||||
model = Models.get_model_by_id(id)
|
||||
# Cache-control headers to prevent stale cached images
|
||||
cache_headers = {"Cache-Control": "no-cache, must-revalidate"}
|
||||
|
||||
if model:
|
||||
if model.meta.profile_image_url:
|
||||
if model.meta.profile_image_url.startswith("http"):
|
||||
return Response(
|
||||
status_code=status.HTTP_302_FOUND,
|
||||
headers={"Location": model.meta.profile_image_url},
|
||||
headers={"Location": model.meta.profile_image_url, **cache_headers},
|
||||
)
|
||||
elif model.meta.profile_image_url.startswith("data:image"):
|
||||
try:
|
||||
@@ -307,14 +310,17 @@ async def get_model_profile_image(id: str, user=Depends(get_verified_user)):
|
||||
return StreamingResponse(
|
||||
image_buffer,
|
||||
media_type="image/png",
|
||||
headers={"Content-Disposition": "inline; filename=image.png"},
|
||||
headers={
|
||||
"Content-Disposition": "inline; filename=image.png",
|
||||
**cache_headers,
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return FileResponse(f"{STATIC_DIR}/favicon.png")
|
||||
return FileResponse(f"{STATIC_DIR}/favicon.png", headers=cache_headers)
|
||||
else:
|
||||
return FileResponse(f"{STATIC_DIR}/favicon.png")
|
||||
return FileResponse(f"{STATIC_DIR}/favicon.png", headers=cache_headers)
|
||||
|
||||
|
||||
############################
|
||||
|
||||
Reference in New Issue
Block a user