Latest articles →  · Tim Riley   Another one of the tweaks I had
to make to accomodate Rails streaming responses was ensuring
that the Rack::Deflater middleware didn’t run on my app’s
streaming actions.  The Deflater middleware gzips your responses
before delivering them to the client. This is useful to run on
the Heroku Cedar stack because this facility is otherwise not
provided. There’s a big gotcha, though: the middleware breaks
Rails HTTP streaming responses. There’s a good explanation of
this on StackOverflow, as well as a monkey patch to
ActionController::Streaming that corrects the behaviour.
module Rack   class DeflaterWithExclusions < Deflater     def
initialize(app, options = {})       @app = app        @exclude =
options[:exclude]      def call(env)       if @exclude &&  And
here’s how the extended middleware is included, in    Wrapping
the middleware in this way has worked well. We get to keep it
for the bulk of the app, where it’s useful, without it
interfering with the parts that are more touc