nginx + memcached + gzip

LinU777 nginx-forum at nginx.us
Thu Sep 4 14:39:03 UTC 2014


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: http://forum.nginx.org/read.php?2,253074,253074#msg-253074



More information about the nginx mailing list