NGINX and wrong memcached output

Maxim Dounin mdounin at mdounin.ru
Sun Apr 22 20:49:48 UTC 2012


Hello!

On Sun, Apr 22, 2012 at 06:48:06PM +0200, Jakub wrote:

> Hi,
> 
> At first let me tell my application was developped under PHP with
> Symfony2, but I guess my problem is about nginx and memcached and not
> about PHP. As I can see here is good community about nginx and I will be
> glad for any help.
> 
> I have problem with nginx and memcached responses such as text/html or
> application/json. My idea is:
> -First request on nginx server (reverse proxy memcached server)
> -Try if I have memcached response (memcached run on same server as
> nginx)
> -If not go to application server
> -Application server makes response
> -Stores response in to memcached
> -And for next same request nginx hit response from memcached and return
> to client.
> 
> But the problem is, when the application server stores response to
> memcached (data in memcached are stored good and corectly) and NGINX hit
> the request in memcached, but return totaly wrong hashed content.
> 
> For example:
> First request, ngingx didnt find response in memcached, pass to
> application server, and here is response ... good and correct JSON.
> ------- Headers
> HTTP/1.0 200 OK
> Date: Sun, 22 Apr 2012 16:13:58 GMT
> Server: Apache/2.2.16 (Debian)
> X-Powered-By: PHP/5.3.3-7+squeeze8
> cache-control: no-cache
> x-debug-token: 4f942e4dee10b
> Content-Length: 476
> Connection: close
> Content-Type: application/json
> -------- Content
> [{"id":10,"title":"Cinema","url":"cinema","articles":null},{"id":2,"title":"Computers","url":"computer","articles":null},{"id":8,"title":"Foto","url":"foto","articles":null},{"id":12,"title":"Literature","url":"literature","articles":null},{"id":4,"title":"Music","url":"music","articles":null},{"id":18,"title":"Society","url":"society","articles":null},{"id":16,"title":"Sport","url":"sport","articles":null},{"id":6,"title":"Travelling","url":"travelling","articles":null}]
> 
> But for the second request, when NGINX find response in memcached, NGINX
> serves totaly wrong.
> -------- Headers
> Connection:keep-alive
> Content-Length:164
> Content-Type:application/json
> Date:Sun, 22 Apr 2012 16:17:15 GMT
> Server:nginx/0.7.67
> -------- Content
> xśuÎ1Â0ŕ˙rs+"’UpŇI·ââ)צ$AÄ˙nˇ59¤ßƒďÝ5o ˜zU0‚=uŘZ¨
> ˘űE„cÓ%ćO5ʵ‚ľí“`ˆĹN͢Ţ}đâ3ĽŹaŐę摆y+)`¶¬«ů…M8ĄH.ŰvJ‡Ő»gďĺ•eĚyÁn•í}"§4ď»űDfęŮŠ®ţ®_ß
> ť
> 
> With text/html I have exactly the same problem. Do you have anybody any
> idea plese? Here is my nginx configuration:

Content stored in memcached is compressed, and nginx just returns 
what you have in memcached.  You have to read docs on your 
memcached client to instruct it to don't do any 
compression/serialization and store raw data instead.

Maxim Dounin



More information about the nginx mailing list