Rack::Sendfile

Last Updated: 22 October 2013

constraints rack ruby sendfile

Table of Contents

Rack::Sendfile is typically used to serve static files directly from the webserver instead of through your Ruby application.

Heroku does not support the use of Rack::Sendfile. Rack:Sendfile usually requires that there is a frontend webserver like nginx or apache is running on the same machine as the application server. This is not how Heroku is architected. Using the Rack::Sendfile middleware will cause your file downloads to fail since it will send a body with Content-Length of 0.

If you have questions about Ruby on Heroku, consider discussing it in the Ruby on Heroku forums.

Rails

By default Rails will set this to nil, but make sure that config.action_dispatch.x_sendfile_header is not set in config/enviroments/production.rb.