Memcached/JSONP

agentzh agentzh at gmail.com
Mon Dec 21 13:12:19 MSK 2009


On Mon, Dec 21, 2009 at 5:40 PM, agentzh <agentzh at gmail.com> wrote:
>    location /blah {
>        echo_duplicate 1 "$arg_callback(";
>        echo_location_async "/data?$uri";
>        echo_duplicate 1 ")";
>    }
>    location /data {
>        echo_duplicate 1 '{"dog":"$query_string"}';
>    }
>

Well, there's more than one way to do it, actually. A more concise and
faster version is given below:

    location /blah {
        echo_before_body "$arg_callback(";

        echo_duplicate 1 '{"dog":"$uri"}';

        echo_after_body ")";
    }

The "echo_before_body" and "echo_after_body" directives work exactly
in an output filter. And no extra cost of subrequests is needed here
:D

The output might be a bit ugly due to 1 extra new line:

    ding1111111(
    {"dog":"/blah/9999999.json"})

But...it's not that bad anyway ;)

TMTOWTDI!
-agentzh



More information about the nginx mailing list