Pleroma v1.1.9-10-g42f76306+dev Pleroma.Plugs.Cache View Source

Caches successful GET responses.

To enable the cache add the plug to a router pipeline or controller:

plug(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 or nil to disable expiration. Defaults to nil.
  • query_params: Take URL query string into account (true), ignore it (false) or limit to specific params only (list). Defaults to true.

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