-
- Downloads
Add caching support to media endpoints (#18235)
We do a few things in this PR to better support caching:
1. Change `Cache-Control` header 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 a
`If-None-Match` header, at which point Synapse can check auth and
respond with a 304 and empty content.
2. Add `ETag` response header to all media responses. We hardcode this
to `1` since all media is immutable (beyond being deleted).
3. Check for `If-None-Match` header (after checking for auth), and if it
matches then respond with a 304 and empty body.
---------
Co-authored-by:
Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Showing
- changelog.d/18235.misc 1 addition, 0 deletionschangelog.d/18235.misc
- synapse/media/_base.py 67 additions, 7 deletionssynapse/media/_base.py
- synapse/media/media_repository.py 17 additions, 0 deletionssynapse/media/media_repository.py
- synapse/media/thumbnailer.py 19 additions, 0 deletionssynapse/media/thumbnailer.py
- tests/federation/test_federation_media.py 39 additions, 0 deletionstests/federation/test_federation_media.py
- tests/rest/client/test_media.py 110 additions, 0 deletionstests/rest/client/test_media.py
Loading
Please register or sign in to comment