-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Hi.
Is there any way to make nginx return empty_gif or result with "return ...;" instead of returning result received from memcache?
If this read by "agentzh", i was inspired by your slides at http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html .
location ~ /app/counter/(\d+)$ {
empty_gif;
#echo_exec /safe-memc?cmd=incr&key=id$1&val=1;
echo_location_async /safe-memc?cmd=incr&key=id$1&val=1&exptime=0;
}
# (not quite) REST interface to our memcached server
location = /memc {
internal;
set $memc_cmd $arg_cmd;
set $memc_key $arg_key;
set $memc_value $arg_val;
set $memc_exptime $arg_exptime;
memc_pass memcached_upstream2;
}
# (not quite) REST interface to our memcached server
location = /safe-memc {
internal;
set $memc_cmd $arg_cmd;
set $memc_key $arg_key;
set $memc_value $arg_val;
set $memc_exptime $arg_exptime;
memc_pass memcached_upstream2;
error_page 404 @safe-memc-add-and-retry;
}
location @safe-memc-add-and-retry {
internal;
echo_location /memc?cmd=add&key=$arg_key&val=0;
echo_location /memc?$query_string;
}
I just basically use the example from http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html#45 slightly modified to adopt for my case.
I want to do a simple counter here.
The only problem is that in result to /app/counter/1 and so on it return a number (the result of SET query to memcache). But i want it simply return empty_gif. I've tried various settings but can't get it working. It completely ignores empty_gif and return directivities. Can you give me an idea please?
If possible, it would be also to cool to know how to make it really async. Because now, when it returns result, it basically waits for it (otherwise it should not return anything). I want this operation to happen in background after connection close (or better request end, not sure does that really possible - to stay keepalive connection but end current request).