Welcome! Log In Create A New Profile

Advanced

Re: $memcached_key doesn't fetch unicode url

Maxim Dounin
May 08, 2014 09:14PM
Hello!

On Sun, May 04, 2014 at 06:42:39PM +0300, kirpit wrote:

> Hi,
>
> I'm doing some sort of downstream cache that I save every entire page into
> memcached from the application with urls such as:
>
> www.example.com/file/path/?query=1
>
> then I'm fetching them from nginx if available with the config:
> location / {
> # try to fetch from memcached
> set $memcached_key "$host$request_uri";
> memcached_pass localhost:11211;
> expires 10m;
> # not fetched from memcached, fallback
> error_page 404 405 502 = @fallback;
> }
>
>
> This works perfectly fine for latin char urls. However, it fails to catch
> unicode urls such as:
>
> www.example.com/flights/istc-lonc-11062014/lonc-istc-19062014/Cheap-return-tickets-from-%C4%B0stanbul-to-Londra-in-Haziran.html?class=economy&adult=1
>
> The unicode char "%C4%B0" appears same in the nginx logs, application cache
> setting key (that is actually taken from raw REQUEST_URI what nginx gives).
>
> The example url content also exist in the memcached itself when if I try:
> "get
> www.example.com/flights/istc-lonc-11062014/lonc-istc-19062014/Cheap-return-tickets-from-%C4%B0stanbul-to-Londra-in-Haziran.html?class=economy&adult=1
> "
>
> However, nginx cannot fetch anything from memcached, @fallbacks every time.
>
> I'm using version 1.6.0. Any help is much appreciated.

Value of $memcached_key is escaped to make sure memcached protocol
constraints are not violated - most notably, space and "%"
character are escaped into "%20" and "%25", respectively (space is
escaped as it's not allowed in memcached keys, and "%" to make the
escaping reversible).

Given the

www.example.com/flights/istc-lonc-11062014/lonc-istc-19062014/Cheap-return-tickets-from-%C4%B0stanbul-to-Londra-in-Haziran.html?class=economy&adult=1

$memcached_key, nginx will try to fetch

www.example.com/flights/istc-lonc-11062014/lonc-istc-19062014/Cheap-return-tickets-from-%25C4%25B0stanbul-to-Londra-in-Haziran.html?class=economy&adult=1

from memcached.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

$memcached_key doesn't fetch unicode url

roy.enjoy May 04, 2014 11:44AM

Re: $memcached_key doesn't fetch unicode url

Maxim Dounin May 08, 2014 09:14PM

Re: $memcached_key doesn't fetch unicode url

roy.enjoy May 09, 2014 05:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 235
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready