Repository navigation
fix(sftp): stop the browser cache from serving a stale download - #355
Merged
Merged
Conversation
Owner
|
Thanks! @antoinekh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #354
Problem
After a remote file is rewritten under the same path, downloading it again from the SFTP panel returns the previous content. The editor's Download button and Open locally are affected the same way; with Open locally, saving the file back then fails with
SFTP_FILE_CHANGED.Cause
GET /api/sftp/:connId/downloadsendsLast-Modifiedbut noCache-Control, and the client fetches it with a plainfetch(). The response is then heuristically fresh (RFC 9111 §4.2.2): Chromium serves it from the HTTP cache for 10% of the file's age without asking the server, so about 12 hours for a file last changed 5 days ago.Fix
The route now sends
cache-control: no-store, as/api/sftp/:connId/drag-downloadalready does.Last-Modifiedstays: Open locally still reads it for its upload check.Testing
cache-controlheader. It fails without the change (expected undefined to be 'no-store') and passes with it.pnpm typecheckandpnpm lintpass.pnpm test: 2463 tests pass. The only failing suite isunit/electron/web-windows.test.ts, because the Electron binary download failed on my machine (Electron failed to install correctly); it is unrelated to this change.