Nginx + memcached + gzip

Hello.

I have service with memcached for storing large xml data. Data is
compressed
in memcached. I want to send responce gzipped if client supports that
and
decompressed if not. But with my config responce goes to client always
decompressed. There is my site config:

server {
listen 80;
server_name static.app1.feeds.lan;

location / {
    memcached_pass 10.10.0.11:11211;
    gunzip on;
    memcached_gzip_flag 2;
    gzip_static on;
    gzip on;
    gzip_proxied any;
    gzip_types "text/xml";
    gzip_vary on;

    set $memcached_key "null";
    if ($uri ~* "/uploads/(.*)/feed.xml") {
        set $memcached_key $1;
    }
}

}

and nginx config:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 16384;
# multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_types text/plain text/css application/json

application/x-javascript text/xml application/xml application/xml+rss
text/javascript;
…

Thanks!

Posted at Nginx Forum:

I have checked with curl:

curl -I http://static.app1.feeds.lan/uploads/one_feed/1/feed.xml
–compressed

HTTP/1.1 200 OK
Server: nginx/1.6.1
Date: Thu, 04 Sep 2014 14:39:54 GMT
Content-Type: text/xml
Connection: keep-alive
Vary: Accept-Encoding

curl -I http://static.app1.feeds.lan/uploads/one_feed/1/feed.xml

HTTP/1.1 200 OK
Server: nginx/1.6.1
Date: Thu, 04 Sep 2014 14:39:59 GMT
Content-Type: text/xml
Connection: keep-alive
Vary: Accept-Encoding

Posted at Nginx Forum: