An example use case where we cache the response body for a regular HTTP request and individual chunks for a chunked response like SSEs:
# register lifecycle callback to cache response
conn
|> register_before_send(fn conn ->
if conn.resp_body do
Dreamcatcher.SemanticCache.API.put(key, conn.resp_body)
end
conn
end)
|> register_before_chunk(fn conn, chunk ->
if chunk do
Dreamcatcher.SemanticCache.API.append_chunk(key, chunk)
end
conn
end)
Resolves #1153
An example use case where we cache the response body for a regular HTTP request and individual chunks for a chunked response like SSEs: