What is rails3_disable_x_sendfile? | Trevor Turk | 3/21/11 4:20 AM | I'm seeing the following when pushing to Heroku: Configure Rails 3 to disable x-sendfile Installing rails3_disable_x_sendfile... done What is this about? Is there a way I should configure my app to avoid seeing this message? |
Re: What is rails3_disable_x_sendfile? | Keenan Brock | 3/21/11 4:38 AM | Hi Trevor, config/environments/production.rb line 12
And while you are in there, you may want to tweak
Best of luck, Keenan -- |
Re: What is rails3_disable_x_sendfile? | Trevor Turk | 3/21/11 4:45 AM | I have: config.serve_static_assets = true ...but I don't have anything with: config.action_dispatch.x_sendfile_header ...at all. Perhaps you are doing something unnecessarily in my case? You can view my app "teamlab" yourself on Heroku if you like. I can file a support ticket if necessarily. Also, you didn't answer my first question: "what is this about" ? :) Thanks, - Trevor |
Re: What is rails3_disable_x_sendfile? | Keenan Brock | 3/21/11 5:06 AM | Hello Trevor, Web servers (e.g.: Apache) is tuned for serving up static files. But sometimes, your ruby code generates a file that needs to be streamed. Or it uses logic to determine the name of an existing file that needs to be streamed. So there is a mechanism for ruby to set a header (X-sendfile), asking apache to stream the file for it. This is nice: I think lighttpd introduced the flag, but I digress.
So you need to tell rails to not use the handy X-sendfile header and stream the file through.
The web server is running on a different machine than the dynos. So X-sendfile doesn't work. But this tweaking takes a few seconds during slug generation, and they are tweaking your configuration. So they give you a warning to let you know.
> -- |
Re: What is rails3_disable_x_sendfile? | Trevor Turk | 3/21/11 6:59 AM | On Monday, March 21, 2011 12:06:35 PM UTC, Keenan wrote: Thanks for the explanation, Keenan. Sorry, I thought you worked for Heroku! :) I'll follow up with Heroku directly about it. - Trevor |
Re: What is rails3_disable_x_sendfile? | logicaltext | 3/22/11 7:44 AM | Hi Trevor,
Keenan is right in that Heroku doesn't support the X-sendfile method: - http://devcenter.heroku.com/articles/rack-sendfile The support team initially added this documentation last year after I submitted an issue regarding problems I was having serving Sass- generated files from `./tmp` using Rack::Static. The relevant part of my Rails configuration looked like this: Sass::Plugin.options[:template_location] = { "#{Rails.root}/app/stylesheets" => "#{Rails.root}/tmp/stylesheets" } Rails.configuration.middleware.insert_after 'Sass::Plugin::Rack', 'Rack::Static', :urls => ['/stylesheets'], :root => "#{Rails.root}/tmp" This worked in a simple Rack app, but not in Rails--I kept getting a 503 error. A member of the Heroku support team suggested that I remove Rack::Sendfile from my middleware stack, and that solved the issue. Since Rack::Static delegates to Rack::File, Rack::Sendfile will add the `X-Sendfile` header. And since Heroku doesn't support the use of Rack::Sendfile, file downloads will fail. When I first found about this, I just removed Rack::Sendfile from my middleware stack, but it seems Heroku is now getting round this automatically by configuring Rails to disable the `X-Sendfile` header. |