Skip to content

Commit 66e2d98

Browse files
committed
docs: bumped version number to 0.6.5 and also documented the trick for doing background async jobs by using ngx.eof() + keepalive_timeout 0.
1 parent 0c14852 commit 66e2d98

File tree

3 files changed

+72
-7
lines changed

3 files changed

+72
-7
lines changed

README

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Status
88
This module is under active development and is production ready.
99

1010
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
1313
September 2012.
1414

1515
Synopsis
@@ -3018,7 +3018,34 @@ Nginx API for Lua
30183018

30193019
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
30203020

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;
30223049

30233050
ngx.sleep
30243051
syntax: *ngx.sleep(seconds)*

README.markdown

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This module is under active development and is production ready.
1818
Version
1919
=======
2020

21-
This document describes ngx_lua [v0.6.4](https://github.com/chaoslawful/lua-nginx-module/tags) released on 9 September 2012.
21+
This document describes ngx_lua [v0.6.5](https://github.com/chaoslawful/lua-nginx-module/tags) released on 15 September 2012.
2222

2323
Synopsis
2424
========
@@ -2786,7 +2786,26 @@ ngx.eof
27862786

27872787
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
27882788

2789-
Explicitly specify the end of the response output stream.
2789+
Explicitly specify the end of the response output stream. In the case of HTTP 1.1 chunked encoded output, it will just trigger the Nginx core to send out the "last chunk".
2790+
2791+
When you disable the HTTP 1.1 keep-alive feature for your downstream connections, you can rely on descent HTTP clients to close the connection actively for you when you call this method. This trick can be used do back-ground jobs without letting the HTTP clients to wait on the connection, as in the following example:
2792+
2793+
2794+
location = /async {
2795+
keepalive_timeout 0;
2796+
content_by_lua '
2797+
ngx.say("got the task!")
2798+
ngx.eof() -- descent HTTP client will close the connection at this point
2799+
-- access MySQL, PostgreSQL, Redis, Memcached, and etc here...
2800+
';
2801+
}
2802+
2803+
2804+
But if you create subrequests to access other locations configured by Nginx upstream modules, then you should configure those upstream modules to ignore client connection abortions if they are not by default. For example, by default the standard [HttpProxyModule](http://wiki.nginx.org/HttpProxyModule) will terminate both the subrequest and the main request as soon as the client closes the connection, so it is important to turn on the [proxy_ignore_client_abort](http://wiki.nginx.org/HttpProxyModule#proxy_ignore_client_abort) directive in your location block configured by [HttpProxyModule](http://wiki.nginx.org/HttpProxyModule):
2805+
2806+
2807+
proxy_ignore_client_abort on;
2808+
27902809

27912810
ngx.sleep
27922811
---------

doc/HttpLuaModule.wiki

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This module is under active development and is production ready.
1010

1111
= Version =
1212

13-
This document describes ngx_lua [https://github.com/chaoslawful/lua-nginx-module/tags v0.6.4] released on 9 September 2012.
13+
This document describes ngx_lua [https://github.com/chaoslawful/lua-nginx-module/tags v0.6.5] released on 15 September 2012.
1414

1515
= Synopsis =
1616
<geshi lang="nginx">
@@ -2699,7 +2699,26 @@ It is strongly recommended to combine the <code>return</code> statement with thi
26992699
27002700
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
27012701
2702-
Explicitly specify the end of the response output stream.
2702+
Explicitly specify the end of the response output stream. In the case of HTTP 1.1 chunked encoded output, it will just trigger the Nginx core to send out the "last chunk".
2703+
2704+
When you disable the HTTP 1.1 keep-alive feature for your downstream connections, you can rely on descent HTTP clients to close the connection actively for you when you call this method. This trick can be used do back-ground jobs without letting the HTTP clients to wait on the connection, as in the following example:
2705+
2706+
<geshi lang="nginx">
2707+
location = /async {
2708+
keepalive_timeout 0;
2709+
content_by_lua '
2710+
ngx.say("got the task!")
2711+
ngx.eof() -- descent HTTP client will close the connection at this point
2712+
-- access MySQL, PostgreSQL, Redis, Memcached, and etc here...
2713+
';
2714+
}
2715+
</geshi>
2716+
2717+
But if you create subrequests to access other locations configured by Nginx upstream modules, then you should configure those upstream modules to ignore client connection abortions if they are not by default. For example, by default the standard [[HttpProxyModule]] will terminate both the subrequest and the main request as soon as the client closes the connection, so it is important to turn on the [[HttpProxyModule#proxy_ignore_client_abort|proxy_ignore_client_abort]] directive in your location block configured by [[HttpProxyModule]]:
2718+
2719+
<geshi lang="nginx">
2720+
proxy_ignore_client_abort on;
2721+
</geshi>
27032722
27042723
== ngx.sleep ==
27052724
'''syntax:''' ''ngx.sleep(seconds)''

0 commit comments

Comments
 (0)