forked from AkkomaGang/akkoma
Merge branch 'proxy-no-default-plug-cache' into 'develop'
Always override plug's default cache-control in reverse proxy See merge request pleroma/pleroma!692
This commit is contained in:
commit
3f9c778320
1 changed files with 17 additions and 4 deletions
|
@ -275,11 +275,24 @@ defp build_resp_headers(headers, opts) do
|
||||||
|
|
||||||
defp build_resp_cache_headers(headers, _opts) do
|
defp build_resp_cache_headers(headers, _opts) do
|
||||||
has_cache? = Enum.any?(headers, fn {k, _} -> k in @resp_cache_headers end)
|
has_cache? = Enum.any?(headers, fn {k, _} -> k in @resp_cache_headers end)
|
||||||
|
has_cache_control? = List.keymember?(headers, "cache-control", 0)
|
||||||
|
|
||||||
if has_cache? do
|
cond do
|
||||||
|
has_cache? && has_cache_control? ->
|
||||||
headers
|
headers
|
||||||
else
|
|
||||||
List.keystore(headers, "cache-control", 0, {"cache-control", @default_cache_control_header})
|
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"})
|
||||||
|
|
||||||
|
true ->
|
||||||
|
List.keystore(
|
||||||
|
headers,
|
||||||
|
"cache-control",
|
||||||
|
0,
|
||||||
|
{"cache-control", @default_cache_control_header}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue