Does anyone know if there is a way to prevent Sinatra from sending the 'Connection: close' header in its responses?
To be clear, I have a very simple
get '/path' do
puts "Some (~200 byte long) string"
end
But, afte开发者_JAVA技巧r looking at the output in a network analyser, I see it's sending the Connection: close
header right after the HTTP/1.1 200 OK
, which I'd like to stop!
Ah ha! It seems Mongrel, the server my Sinatra app was running on, doesn't support Keep-Alive. so I just did:
set :server, 'thin'
after gem install thin
and everything seems to be working better!
I don't speak Ruby at all, and the Sinatra site isn't terribly clear on what it is (is it a framework for Ruby?) so I might be completely off my rocker here, but:
Connection: close
is sent by your Web server when keep alives are turned off. For scalability reasons, keep alives are generally considered to be step one on things to turn off in your server. To be fair, there's a school of thought both ways, particularly when Ajax is involved.
I use nginx for my Django work (I'm thinking it's similar), and I have keep-alives turned off in nginx like this:
14:58 jsmith@lateralus% grep alive /etc/nginx/nginx.conf ~
keepalive_timeout 0;
Apache uses KeepAlive (see here).
If Sinatra is its own Web server, I can't find any documentation to turn keep alives on, and I'll go ahead and eat the fact that I look like an idiot.
精彩评论