Skip to content

Commit c5079e4

Browse files
Merge pull request rails#47933 from renny-ren/update-sse-docs
Update docs about SSE streaming response
2 parents c493712 + 80c6cd8 commit c5079e4

File tree

1 file changed

+15
-0
lines changed
  • actionpack/lib/action_controller/metal

1 file changed

+15
-0
lines changed

actionpack/lib/action_controller/metal/live.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ module ActionController
3434
# The final caveat is that your actions are executed in a separate thread than
3535
# the main thread. Make sure your actions are thread safe, and this shouldn't
3636
# be a problem (don't share state across threads, etc).
37+
#
38+
# Note that Rails includes `Rack::ETag` by default, which will buffer your
39+
# response. As a result, streaming responses may not work properly with Rack
40+
# `2.2.x`, and you may need to implement workarounds in your application.
41+
# You can either set the `ETag` or `Last-Modified` response headers or remove
42+
# `Rack::ETag` from the middleware stack to address this issue.
43+
#
44+
# Here's an example of how you can set the `Last-Modified` header if your Rack
45+
# version is `2.2.x`:
46+
#
47+
# def stream
48+
# response.headers["Content-Type"] = "text/event-stream"
49+
# response.headers["Last-Modified"] = Time.now.httpdate # Add this line if your Rack version is 2.2.x
50+
# ...
51+
# end
3752
module Live
3853
extend ActiveSupport::Concern
3954

0 commit comments

Comments
 (0)