Http Streaming for Pheonix Framework Like Rails ActionController::Streaming

Hi,

I’m new to the phoenix framework and loving it so far. I’m kind of exploring and learning different aspects of Phoenix and LiveView as an alternative to SPA. I was wondering if there is HTTP streaming support similar to Rails ActionController::Streaming where you get the layout first and then the data slowly being streamed to the client without waiting for server backend work to finish for the initial render.

You can read more here: ActionController::Streaming

Allows views to be streamed back to the client as they are rendered.

By default, Rails renders views by first rendering the template and then the layout. The response is sent to the client after the whole template is rendered, all queries are made, and the layout is processed.

Streaming inverts the rendering flow by rendering the layout first and streaming each part of the layout as they are processed. This allows the header of the HTML (which is usually in the layout) to be streamed back to client very quickly, allowing JavaScripts and stylesheets to be loaded earlier than usual.

Many thanks!
Lior

Plug.Conn.send_chunked/2

1 Like