mirror of
https://github.com/open-webui/computer.git
synced 2026-11-05 01:17:24 +00:00
[GH-ISSUE #248] bug: File preview serves stale content for unchanged file paths #162
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
open-webui/computer#162
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JKGeovision on GitHub (Aug 31, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/248
Hello,
I discovered that the in-app file preview keeps showing stale content when a workspace file is modified in place (same path, new content), because the mutable file endpoints send no cache policy and the preview refresh does not bypass the browser cache.
Steps to reproduce:
Expected behavior:
Actual behavior:
Root cause analysis:
cptr/routers/workspace.pydefines three mutable file endpoints:serve_static()forGET /api/workspace/files/serve/{file_path:path}(lines 911-935)view_file()forGET /api/workspace/files/view(lines 813-834)download_file()forGET /api/workspace/files/download(lines 840-854)All three return a plain
FileResponsewith noCache-ControlorExpiresheader. Measured live response for the/serveendpoint:(no
Cache-Control, noExpires)Without a cache directive, browsers and WebViews apply heuristic caching to 200 responses and may serve the stored body for an unbounded time. These endpoints serve mutable files behind stable path-based URLs, which is exactly the case that requires an explicit cache policy.
Note: the server also ignores
If-None-Match(always 200, never 304). I verified this by re-requesting with the previous ETag after modifying the file, so even a revalidating client cannot benefit server-side. The observed behavior indicates the client does not even revalidate.Contrast:
routers/files.py:82(immutable upload blobs) correctly sendsCache-Control: public, max-age=31536000, immutable, so the workspace file endpoints appear to have simply been missed.In the bundled frontend build (cptr 0.9.21,
frontend/build/_app/immutable/nodes/2.*.js), the chat HTML preview renders:with
srcset to/api/workspace/files/serve/${filePath}, a stable URL per file path. The preview toolbar's reload action performs a plainiframe.contentWindow.location.reload(). A regularlocation.reload()respects the HTTP cache (no cache-busting parameter, no bypass), so once the WebView has cached the 200 response for that URL, the refresh button re-serves the cached body.Suggested fixes:
/api/workspace/files/serve/*,/view,/download), eitherCache-Control: no-store(simplest), orCache-Control: no-cacheplus 304 handling forIf-None-Match/If-Modified-Since. TheETagandLast-Modifiedheaders are already sent byFileResponse, so revalidation would be cheap.?v=<file mtime>or?t=<Date.now()>). The/serveroute is path-based and ignores the query string, so this works without any server change. Alternatively, make the refresh action perform a cache-bypassing reload.Workaround:
Preview a copy under a new file name, or open the file in an external browser.
Thank you for your time and consideration.
Best regards,
Joshua Krimmer
@owui-terminator[bot] commented on GitHub (Aug 31, 2026):
🔍 Related Issues Found
I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:
🟢 #246 bug: image previews never render on Windows — frontend sends backslash paths to
/api/workspace/files/serveShares the same
/api/workspace/files/servepreview path and the same frontend preview mechanism. While this issue is about Windows path formatting rather than caching, it confirms the relevant code path and file preview subsystem affected by workspace file rendering.by gucazcode
🟢 #164 bug: problematic cache reuse
Broad cache-related issue, but it concerns inference/prompt caching rather than HTTP/browser caching. It is only tangentially related, so it is a weak match for the new file-preview stale-content bug.
by cclecle
💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.
This comment was generated automatically. React with 👍 if helpful, 👎 if not.
@Classic298 commented on GitHub (Sep 21, 2026):
just hit this from the agent side, not the file explorer: display_file on the same path twice in one chat shows the first render's bytes the second time. agent regenerates the file on disk (new mtime, new size), the inline chat preview stays stale. renaming the path shows the new bytes immediately, which matches the cache diagnosis here.
the workspace file endpoints sending no cache policy is the whole story for me too, the immutable upload endpoint does it correctly. no-cache on the mutable ones would fix both the explorer preview and the chat file cards.