Add Pleroma.Plugs.Cache
Changes
- Add
Pleroma.Plugs.Cache
plug - Setup cache for
ActivityPubController.activity/2
andActivityPubController.object/2
- Close #1174 (closed)
Pleroma.Plugs.Cache Configuration
To configure the plug you need to pass settings as the second argument to the plug/2
macro:
plug(Pleroma.Plugs.Cache, [ttl: nil, query_params: true])
Available options:
-
ttl
: An expiration time (time-to-live). This value should be in milliseconds ornil
to disable expiration. Defaults tonil
. -
query_params
: Take URL query string into account (true
), ignore it (false
) or limit to specific params only (list). Defaults totrue
.
Additionally, you can overwrite the TTL inside a controller action by assigning cache_ttl
to the connection struct:
def index(conn, _params) do
ttl = 60_000 # one minute
conn
|> assign(:cache_ttl, ttl)
|> render("index.html")
end
Edit: Add an ability to specify query param names
Edited by minibikini