Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my web site i've made data caching with memcached. It stores fully generated html pages. Next step was to get this data from memcached by nginx and send back to user w\o starting apache process. First i tried to get data from cache by php backend and it worked. But when i try make this with nginx - i see hardly corrupted data. smth like

i'm asking for help with this problem.

p.s. here the part of nginx config if it can help

location / {
    #add_header    Content-Type  "text/html";
    set $cachable 1;

    if ($request_method = POST){
        set $cachable 0;
    if ($http_cookie ~ "beauty_logged") {
        set $cachable 0;

    if ($cachable = 1) {
        set             $memcached_key   'nginx_$host$uri';

    default_type    text/html;
    error_page      404 502 504 405 = @php;
    #proxy_pass http://front_cluster;

location @php {
    proxy_pass http://front_cluster;
share|improve this question

Nginx does not process the content stored in Memcached, it just gets it and returns to the browser as is.

The real cause is the Memcached client library your application uses. Most of the libraries compress large values (usually when value size exceeds some threshold), so you must configure it not to do so, or set memcached_gzip_flag with gunzip module enabled.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.