Rack hook which fires after the socket to the client is closed.
Switch branches/tags
Clone or download
Latest commit b84d19b Jun 6, 2012


Rack After Reply

A hook for Rack apps which fires after the response has been sent, and the socket to the client has been closed.

This is the ideal time to perform delayable, non-backgroundable tasks, such as garbage collection, stats gathering, flushing logs, etc. without affecting response times at all.


Simply add your callbacks to env['rack_after_reply.callbacks'].

use Rack::ContentLength
use Rack::ContentType, 'text/plain'
run lambda { |env|
  env['rack_after_reply.callbacks'] << lambda { ... }
  [200, {}, ['hi']]


Rack After Request works with these web servers:

To request support for other web servers, open a ticket or submit a patch.


  • Bug reports
  • Source
  • Patches: Fork on Github, send pull request.
    • Ensure patch includes tests.
    • Leave the version alone, or bump it in a separate commit.


Copyright (c) George Ogata. See LICENSE for details.