Rubioli Rubioli - 6 months ago 14
Ruby Question

Ruby on Rails header for sending files In NGINX

My application runs on a Nginx and passenger server. Inside the

I see a line says:

# Specifies the header that your server uses for sending files.
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

How does it Specifies header to sending files? How does Rails sends file without having this turned on?

Is it a good practice so turn this on? Does it make my application to run faster?


The behavior is explained in the send_file documentation

You should use this option, it will make your application faster and it is good practice to do so.

If you don't use this option, the file will be read by the ruby process, sent to nginx and the to then client.