nginx从memcached返回损坏的数据

alo*_*eak 2 memcached nginx

在我的网站上,我用memcached进行了数据缓存.它存储完全生成的html页面.下一步是通过nginx从memcached获取此数据并发送回用户w\o启动apache进程.首先,我试图通过php后端从缓存中获取数据并且它有效.但是,当我尝试使用nginx时 - 我看到几乎没有损坏的数据.喜欢在此输入图像描述

我正在寻求这个问题的帮助.

ps这里是nginx配置的一部分,如果它可以帮助

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

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

    if ($cachable = 1) {
        set             $memcached_key   'nginx_$host$uri';
        memcached_pass  127.0.0.1:11211;
    }

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

location @php {
    proxy_pass http://front_cluster;
}
Run Code Online (Sandbox Code Playgroud)

Ale*_*rov 5

Nginx不处理存储在Memcached中的内容,只是获取它并按原样返回浏览器.

真正的原因是您的应用程序使用的Memcached客户端库.大多数库压缩大值(通常在值大小超过某个阈值时),因此您必须将其配置为不这样做,或者设置memcached_gzip_flag(首先出现在Nginx"unstable"1.3.6中)并启用gunzip模块.