projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
33d8212
)
Allow to skip cache in Cache plug
author
Tusooa Zhu
<tusooa@kazv.moe>
Thu, 5 May 2022 22:39:34 +0000
(18:39 -0400)
committer
FloatingGhost
<hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:47:26 +0000
(20:47 +0100)
Ref: fix-local-public
lib/pleroma/web/plugs/cache.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/web/plugs/cache.ex
b/lib/pleroma/web/plugs/cache.ex
index 935b2d83464fb5f2514c92803a81193d1bf66ba8..b0e44db077e022275828132bf85b52a9b9cdc1b0 100644
(file)
--- a/
lib/pleroma/web/plugs/cache.ex
+++ b/
lib/pleroma/web/plugs/cache.ex
@@
-100,20
+100,19
@@
defmodule Pleroma.Web.Plugs.Cache do
should_cache = not Map.get(conn.assigns, :skip_cache, false)
conn =
should_cache = not Map.get(conn.assigns, :skip_cache, false)
conn =
- unless opts[:tracking_fun] do
- if should_cache do
- @cachex.put(:web_resp_cache, key, {content_type, body}, ttl: ttl)
- end
+ cond do
+ Map.get(conn.assigns, :skip_cache, false) ->
+ conn
- conn
- else
- tracking_fun_data = Map.get(conn.assigns, :tracking_fun_data, nil)
+ !opts[:tracking_fun] ->
+ @cachex.put(:web_resp_cache, key, {content_type, body}, ttl: ttl)
+ conn
- if should_cache do
+ true ->
+ tracking_fun_data = Map.get(conn.assigns, :tracking_fun_data, nil)
@cachex.put(:web_resp_cache, key, {content_type, body, tracking_fun_data}, ttl: ttl)
@cachex.put(:web_resp_cache, key, {content_type, body, tracking_fun_data}, ttl: ttl)
- end
- opts.tracking_fun.(conn, tracking_fun_data)
+
opts.tracking_fun.(conn, tracking_fun_data)
end
put_resp_header(conn, "x-cache", "MISS from Pleroma")
end
put_resp_header(conn, "x-cache", "MISS from Pleroma")