|
8 | 8 | This module is under active development and is production ready. |
9 | 9 |
|
10 | 10 | Version |
11 | | - This document describes ngx_lua v0.6.4 |
12 | | - (<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 9 |
| 11 | + This document describes ngx_lua v0.6.5 |
| 12 | + (<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 15 |
13 | 13 | September 2012. |
14 | 14 |
|
15 | 15 | Synopsis |
@@ -3018,7 +3018,34 @@ Nginx API for Lua |
3018 | 3018 |
|
3019 | 3019 | context: *rewrite_by_lua*, access_by_lua*, content_by_lua** |
3020 | 3020 |
|
3021 | | - Explicitly specify the end of the response output stream. |
| 3021 | + Explicitly specify the end of the response output stream. In the case of |
| 3022 | + HTTP 1.1 chunked encoded output, it will just trigger the Nginx core to |
| 3023 | + send out the "last chunk". |
| 3024 | + |
| 3025 | + When you disable the HTTP 1.1 keep-alive feature for your downstream |
| 3026 | + connections, you can rely on descent HTTP clients to close the |
| 3027 | + connection actively for you when you call this method. This trick can be |
| 3028 | + used do back-ground jobs without letting the HTTP clients to wait on the |
| 3029 | + connection, as in the following example: |
| 3030 | + |
| 3031 | + location = /async { |
| 3032 | + keepalive_timeout 0; |
| 3033 | + content_by_lua ' |
| 3034 | + ngx.say("got the task!") |
| 3035 | + ngx.eof() -- descent HTTP client will close the connection at this point |
| 3036 | + -- access MySQL, PostgreSQL, Redis, Memcached, and etc here... |
| 3037 | + '; |
| 3038 | + } |
| 3039 | + |
| 3040 | + But if you create subrequests to access other locations configured by |
| 3041 | + Nginx upstream modules, then you should configure those upstream modules |
| 3042 | + to ignore client connection abortions if they are not by default. For |
| 3043 | + example, by default the standard [[HttpProxyModule]] will terminate both |
| 3044 | + the subrequest and the main request as soon as the client closes the |
| 3045 | + connection, so it is important to turn on the proxy_ignore_client_abort |
| 3046 | + directive in your location block configured by [[HttpProxyModule]]: |
| 3047 | + |
| 3048 | + proxy_ignore_client_abort on; |
3022 | 3049 |
|
3023 | 3050 | ngx.sleep |
3024 | 3051 | syntax: *ngx.sleep(seconds)* |
|
0 commit comments