Haphazard is an ETS based plug for caching response body. Check the Online Documentation
Add haphazard
to your list of dependencies in mix.exs
:
def deps do
[{:haphazard, "~> 0.4.0"}]
end
put it in applications
applications: [:logger, ..., :haphazard]
Setup in your plug router:
plug Haphazard.Plug
Additional configurations (optional):
plug Haphazard.Plug,
methods: ~w(GET HEAD),
path: ~r/\/myroute/,
ttl: 60_000,
enabled: true
The additional configurations reflect the default values.
Source code is released under MIT License. Check LICENSE for more information.