How do I let nginx close the tcp connection instantly after the request is fulfilled?
Asked
Active
Viewed 2.5k times
14
-
2Can't you just send a `Connection: close` header? – Qantas 94 Heavy Jun 09 '13 at 13:57
-
1By the looks of it in some configs nginx does not close connection but sends response header back with Connection: close as it received it – user377178 May 22 '18 at 13:33
2 Answers
1
The connection is maintained between the server and the browser thanks to the Keep Alive requests exchanged between them.
You can disable the Keep Alive behavior for a particular user agent: see the nginx manual
keepalive_disable ua
You can probably trick your browser to have a given user agent, having the keep alive cut only for your particular needs.
-
It looks like its not possible to change the user agent with an `XMLHTTPRequest`. http://stackoverflow.com/a/5862744/1485952 – fnkr Jun 09 '13 at 14:20
-
3This is not a neat solution because you cannot use arbitrary user-agent strings for this trick. – rjha94 Aug 28 '14 at 17:23