<div dir="ltr">A note to the history that is good to know. <div><br></div><div>Thanks Maxim, even though we choose not to use unicode urls to make things less complicated.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Fri, May 9, 2014 at 4:13 AM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello!<br>
<div><div class="h5"><br>
On Sun, May 04, 2014 at 06:42:39PM +0300, kirpit wrote:<br>
<br>
> Hi,<br>
><br>
> I'm doing some sort of downstream cache that I save every entire page into<br>
> memcached from the application with urls such as:<br>
><br>
> <a href="http://www.example.com/file/path/?query=1" target="_blank">www.example.com/file/path/?query=1</a><br>
><br>
> then I'm fetching them from nginx if available with the config:<br>
>     location / {<br>
>         # try to fetch from memcached<br>
>         set                 $memcached_key "$host$request_uri";<br>
>         memcached_pass      localhost:11211;<br>
>         expires             10m;<br>
>         # not fetched from memcached, fallback<br>
>         error_page          404 405 502 = @fallback;<br>
>     }<br>
><br>
><br>
> This works perfectly fine for latin char urls. However, it fails to catch<br>
> unicode urls such as:<br>
><br>
> <a href="http://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" target="_blank">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</a><br>


><br>
> The unicode char "%C4%B0" appears same in the nginx logs, application cache<br>
> setting key (that is actually taken from raw REQUEST_URI what nginx gives).<br>
><br>
> The example url content also exist in the memcached itself when if I try:<br>
> "get<br>
> <a href="http://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" target="_blank">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</a><br>


> "<br>
><br>
> However, nginx cannot fetch anything from memcached, @fallbacks every time.<br>
><br>
> I'm using version 1.6.0. Any help is much appreciated.<br>
<br>
</div></div>Value of $memcached_key is escaped to make sure memcached protocol<br>
constraints are not violated - most notably, space and "%"<br>
character are escaped into "%20" and "%25", respectively (space is<br>
escaped as it's not allowed in memcached keys, and "%" to make the<br>
escaping reversible).<br>
<br>
Given the<br>
<br>
<a href="http://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" target="_blank">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</a><br>


<br>
$memcached_key, nginx will try to fetch<br>
<br>
<a href="http://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" target="_blank">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</a><br>


<br>
from memcached.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" target="_blank">http://nginx.org/</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</font></span></blockquote></div><br></div>