Add caching support to media endpoints#18235
Merged
erikjohnston merged 7 commits intodevelopfrom Mar 13, 2025
Merged
Conversation
And handle when clients revalidate their cache via `If-None-Match` header and return 304 Not Modified. This allows clients and intermediary proxies to cache media, while allowing them to check auth.
anoadragon453
approved these changes
Mar 13, 2025
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
Mar 27, 2025
Fixes high severity vulnerability *exploited in the wild*! # Synapse 1.127.1 (2025-03-26) ## Security - Fix [CVE-2025-30355](https://www.cve.org/CVERecord?id=CVE-2025-30355) / [GHSA-v56r-hwv5-mxg6](GHSA-v56r-hwv5-mxg6). **High severity vulnerability affecting federation. The vulnerability has been exploited in the wild.** # Synapse 1.127.0 (2025-03-25) No significant changes since 1.127.0rc1. # Synapse 1.127.0rc1 (2025-03-18) ### Features - Update [MSC4140](matrix-org/matrix-spec-proposals#4140) implementation to no longer cancel a user's own delayed state events with an event type & state key that match a more recent state event sent by that user. ([\#17810](element-hq/synapse#17810)) ### Improved Documentation - Fixed a minor typo in the Synapse documentation. Contributed by @karuto12. ([\#18224](element-hq/synapse#18224)) ### Internal Changes - Remove undocumented `SYNAPSE_USE_FROZEN_DICTS` environment variable. ([\#18123](element-hq/synapse#18123)) - Fix detection of workflow failures in the release script. ([\#18211](element-hq/synapse#18211)) - Add caching support to media endpoints. ([\#18235](element-hq/synapse#18235)) ### Updates to locked dependencies * Bump anyhow from 1.0.96 to 1.0.97. ([\#18201](element-hq/synapse#18201)) * Bump bcrypt from 4.2.1 to 4.3.0. ([\#18207](element-hq/synapse#18207)) * Bump bytes from 1.10.0 to 1.10.1. ([\#18227](element-hq/synapse#18227)) * Bump http from 1.2.0 to 1.3.1. ([\#18245](element-hq/synapse#18245)) * Bump sentry-sdk from 2.19.2 to 2.22.0. ([\#18205](element-hq/synapse#18205)) * Bump serde from 1.0.218 to 1.0.219. ([\#18228](element-hq/synapse#18228)) * Bump serde_json from 1.0.139 to 1.0.140. ([\#18202](element-hq/synapse#18202)) * Bump ulid from 1.2.0 to 1.2.1. ([\#18246](element-hq/synapse#18246))
yingziwu
added a commit
to yingziwu/synapse
that referenced
this pull request
Apr 13, 2025
No significant changes since 1.127.0rc1. - Update [MSC4140](matrix-org/matrix-spec-proposals#4140) implementation to no longer cancel a user's own delayed state events with an event type & state key that match a more recent state event sent by that user. ([\#17810](element-hq/synapse#17810)) - Fixed a minor typo in the Synapse documentation. Contributed by @karuto12. ([\#18224](element-hq/synapse#18224)) - Remove undocumented `SYNAPSE_USE_FROZEN_DICTS` environment variable. ([\#18123](element-hq/synapse#18123)) - Fix detection of workflow failures in the release script. ([\#18211](element-hq/synapse#18211)) - Add caching support to media endpoints. ([\#18235](element-hq/synapse#18235)) * Bump anyhow from 1.0.96 to 1.0.97. ([\#18201](element-hq/synapse#18201)) * Bump bcrypt from 4.2.1 to 4.3.0. ([\#18207](element-hq/synapse#18207)) * Bump bytes from 1.10.0 to 1.10.1. ([\#18227](element-hq/synapse#18227)) * Bump http from 1.2.0 to 1.3.1. ([\#18245](element-hq/synapse#18245)) * Bump sentry-sdk from 2.19.2 to 2.22.0. ([\#18205](element-hq/synapse#18205)) * Bump serde from 1.0.218 to 1.0.219. ([\#18228](element-hq/synapse#18228)) * Bump serde_json from 1.0.139 to 1.0.140. ([\#18202](element-hq/synapse#18202)) * Bump ulid from 1.2.0 to 1.2.1. ([\#18246](element-hq/synapse#18246))
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.
We do a few things in this PR to better support caching:
Cache-Controlheader to allow intermediary proxies to cache media only if they revalidate on every request. This means that the intermediary cache will still send the request to Synapse but with aIf-None-Matchheader, at which point Synapse can check auth and respond with a 304 and empty content.ETagresponse header to all media responses. We hardcode this to1since all media is immutable (beyond being deleted).If-None-Matchheader (after checking for auth), and if it matches then respond with a 304 and empty body.