agentzh agentzh at
Wed Dec 23 08:47:27 MSK 2009

On Wed, Dec 23, 2009 at 1:12 PM, dylanz <nginx-forum at> wrote:
> Great point!  What you proposed is almost there, but, I don't want the $query_string, but simply the path.

Understood. How about this?

   location /first {
     echo "before";
     echo_location_async /second $uri;
     echo "after";

   location = /second {
     set $memcached_key $query_string;

If you're actually worried about special characters in the parsed URI
in $uri when feeding it as a memcached key, try Marcus Clyne's
ngx_set_var module to pre-hash the key ;)

> I've tried a few different combinations of location directives, but can't seem to get it right.  For example:
> If I made a request to:
> /first/11111.ext?callback=222222
> I'd want to look up the following path in Memcached:
> /first/11111.ext
> So, when I do that echo_async_location, I don't see how I'm able to extrapolate the path out.

Use $uri rather than $request_uri. I know the difference between these
two is very subtle, especially when not looking into the source. Blame
Igor or some others ;)

> If there was an internal variable that held the $uri, minus the $query_string, that would do it!
> However, I don't think that exists at the moment.

$uri is the parsed form of $request_uri, with query string excluded.
And $request_uri is always the main request's URI while $uri is the
current (sub)request's :)


More information about the nginx mailing list