diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-16 14:25:55 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-16 14:25:55 +0300 |
commit | f0651730bdf018b713e21ce718719c7781398362 (patch) | |
tree | 836e0fbcbb49f0ae78635a268e30013c0e94aea7 /lib/pleroma/reverse_proxy | |
parent | 98ed0d1c4bd2db354154cc4a1d1e6530eb68f499 (diff) | |
parent | c2527b8c63a4e35b121981efe2c39cc54c77648d (diff) | |
download | pleroma-f0651730bdf018b713e21ce718719c7781398362.tar.gz |
Merge branch 'develop' into gun
Diffstat (limited to 'lib/pleroma/reverse_proxy')
-rw-r--r-- | lib/pleroma/reverse_proxy/reverse_proxy.ex | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/pleroma/reverse_proxy/reverse_proxy.ex b/lib/pleroma/reverse_proxy/reverse_proxy.ex index 35b973b56..4bbeb493c 100644 --- a/lib/pleroma/reverse_proxy/reverse_proxy.ex +++ b/lib/pleroma/reverse_proxy/reverse_proxy.ex @@ -5,7 +5,7 @@ defmodule Pleroma.ReverseProxy do @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since) ++ ~w(if-unmodified-since if-none-match if-range range) - @resp_cache_headers ~w(etag date last-modified cache-control) + @resp_cache_headers ~w(etag date last-modified) @keep_resp_headers @resp_cache_headers ++ ~w(content-type content-disposition content-encoding content-range) ++ ~w(accept-ranges vary) @@ -32,9 +32,6 @@ defmodule Pleroma.ReverseProxy do * request: `#{inspect(@keep_req_headers)}` * response: `#{inspect(@keep_resp_headers)}` - If no caching headers (`#{inspect(@resp_cache_headers)}`) are returned by upstream, `cache-control` will be - set to `#{inspect(@default_cache_control_header)}`. - Options: * `redirect_on_failure` (default `false`). Redirects the client to the real remote URL if there's any HTTP @@ -291,16 +288,17 @@ defmodule Pleroma.ReverseProxy do defp build_resp_cache_headers(headers, _opts) do has_cache? = Enum.any?(headers, fn {k, _} -> k in @resp_cache_headers end) - has_cache_control? = List.keymember?(headers, "cache-control", 0) cond do - has_cache? && has_cache_control? -> - headers - has_cache? -> - # There's caching header present but no cache-control -- we need to explicitely override it - # to public as Plug defaults to "max-age=0, private, must-revalidate" - List.keystore(headers, "cache-control", 0, {"cache-control", "public"}) + # There's caching header present but no cache-control -- we need to set our own + # as Plug defaults to "max-age=0, private, must-revalidate" + List.keystore( + headers, + "cache-control", + 0, + {"cache-control", @default_cache_control_header} + ) true -> List.keystore( |