fix(desktop): forward cache headers in media proxy#549
Merged
Conversation
Collaborator
Author
Codex review (gpt-5.5)Ran Verdict: No findings.
(Codex inspected both proxy paths, the relay-side cache-control source in |
WKWebView fetches images via the localhost media proxy and the sprout-media:// protocol handler. Both paths only forwarded a hard-coded allowlist of headers (content-type, content-range, accept-ranges, content-length) and stripped everything else — including `Cache-Control`, which the relay already sets to `public, max-age=31536000, immutable` for content-addressed media. Without those headers WKWebView treats every response as uncacheable and re-fetches every image on each channel switch. Forward `cache-control`, `etag`, and `last-modified` in both proxy paths. Media URLs are sha256-addressed, so the upstream's immutable caching directive is safe to honor verbatim. `etag`/`last-modified` are forwarded too in case the relay ever starts sending them. Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
99c2b59 to
8d6711d
Compare
This was referenced May 28, 2026
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.
Why
Images re-download on every channel switch. The relay already sends
Cache-Control: public, max-age=31536000, immutablefor content-addressedmedia (see
crates/sprout-relay/src/api/media.rs), but the desktop'slocalhost media proxy and
sprout-media://protocol handler both forwardonly a hard-coded allowlist:
content-type,content-range,accept-ranges,content-lengthEverything else — including
Cache-Control— is stripped, so WKWebViewtreats every response as uncacheable.
What
Forward
cache-control,etag, andlast-modifiedin both code pathsin
desktop/src-tauri/src/media_proxy.rs.Media URLs are sha256-addressed, so honoring the upstream's immutable
caching directive verbatim is safe — the content at a given URL cannot
change.
etagandlast-modifiedare forwarded for future-proofing.Verification
just desktop-tauri-checkpasses.just desktop-tauri-fmt-checkpasses.hooks before merge (
just ci).Risk
Low. The change is additive — three more header names in a forwarding
allowlist. No behaviour change for responses where the relay doesn't
send the headers.