From ac2dbb3513b2e6ff24624f30a2a8b1bd51bdabc5 Mon Sep 17 00:00:00 2001 From: Till <2353100+S7evinK@users.noreply.github.com> Date: Wed, 3 Aug 2022 10:55:21 +0200 Subject: [PATCH] Add Cache-Control header to media endpoints (#2612) * Add Cache-Control header * Raise rate_limiting threshold to 20 --- dendrite-sample.monolith.yaml | 2 +- dendrite-sample.polylith.yaml | 2 +- mediaapi/routing/routing.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dendrite-sample.monolith.yaml b/dendrite-sample.monolith.yaml index a34b8af5..816c4cae 100644 --- a/dendrite-sample.monolith.yaml +++ b/dendrite-sample.monolith.yaml @@ -192,7 +192,7 @@ client_api: # and appservice users are exempt from rate limiting by default. rate_limiting: enabled: true - threshold: 5 + threshold: 20 cooloff_ms: 500 exempt_user_ids: # - "@user:domain.com" diff --git a/dendrite-sample.polylith.yaml b/dendrite-sample.polylith.yaml index 55061122..4784dbaf 100644 --- a/dendrite-sample.polylith.yaml +++ b/dendrite-sample.polylith.yaml @@ -195,7 +195,7 @@ client_api: # and appservice users are exempt from rate limiting by default. rate_limiting: enabled: true - threshold: 5 + threshold: 20 cooloff_ms: 500 exempt_user_ids: # - "@user:domain.com" diff --git a/mediaapi/routing/routing.go b/mediaapi/routing/routing.go index 19690818..9dcfa955 100644 --- a/mediaapi/routing/routing.go +++ b/mediaapi/routing/routing.go @@ -149,6 +149,9 @@ func makeDownloadAPI( } } + // Cache media for at least one day. + w.Header().Set("Cache-Control", "public,max-age=86400,s-maxage=86400") + Download( w, req,