Welcome! Log In Create A New Profile

Advanced

Content Encoding Error while returning data from memcached stored by ngx_srcache

March 16, 2012 07:58AM
I need little help here. First time browsing or memcached restart will show you the data correctly; but when you refresh second time and it will gives you content encoding error and I think it is something to do with my nginx or ngx_srcache config for fetching data from memcached. I checked using Wireshark from the client-end and found nginx sending uncompressed data and I can see the Accept-encoding and Connection-encoding on request and response header are set respectively. I suspect the error triggers due to browser expect compressed data instead of uncompressed data.

Backend I get uncompressed data and I assume that ngx_srcache will compress said data before storing them on memcached. If ngx_srcache compress data and store them in memcached by default, how do we pass client accept encoding to memcached via ngx_srcache which is not happening. If I use gzip off; then I get data properly.

Here are my configurations:

uname -a
Linux abmx-test 2.6.18-194.el5PAE #1 SMP Tue Mar 16 22:00:21 EDT 2010 i686 i686 i386 GNU/Linux

./nginx -V
nginx version: nginx/1.1.17
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
TLS SNI support disabled
configure arguments: --add-module=./contrib/echo-nginx-module-6c1f553 --add-module=./contrib/memc-nginx-module-4007350 --add-module=./contrib/simpl-ngx_devel_kit-24202b4 --add-module=./contrib/set-misc-nginx-module-e6a54ab --add-module=./contrib/srcache-nginx-module-86e7a18 --with-debug --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-mail_ssl_module

nginx.conf
user nginx;
worker_processes 1;

error_log /usr/local/nginx/logs/error.log debug;
pid /usr/local/nginx/logs/nginx.pid;


events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;
gzip on;
gzip_static on;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_comp_level 8;
gzip_http_version 1.1;
gzip_min_length 512;
gzip_types text/plain text/css application/json application/x-javascript application/xml application/xml+rss text/javascript application/javascript text/x-js application/x-shockwave-flash text/json;
gzip_vary on;


upstream my_mem {
server 127.0.0.1:11211;
}

server {
listen 80;
server_name localhost;

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

default_type application/json;

location = /memc {
internal;

memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;

set $memc_key $query_string;
set $memc_exptime 30;
# set $memc_exptime $arg_exptime;

memc_pass my_mem;
}

location /mix2 {
default_type "application/json;charset=UTF-8";
set $key $args;
srcache_fetch GET /memc key=$key;
srcache_store PUT /memc key=$key;
srcache_store_statuses 200 301 302 404;
srcache_response_cache_control off;

# No data found in memcached
proxy_pass http://192.168.20.101;
proxy_set_header Accept-Encoding "";

}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

}
}

Error log when there is not data in memcached
http://pastebin.com/fUeD2yCA

Error log when there is data in memcahced
http://pastebin.com/Vism9Yyp

Please advice.
Subject Author Posted

Content Encoding Error while returning data from memcached stored by ngx_srcache

n1xman March 16, 2012 07:58AM

Re: Content Encoding Error while returning data from memcached stored by ngx_srcache

agentzh March 16, 2012 08:32AM

Re: Content Encoding Error while returning data from memcached stored by ngx_srcache

n1xman March 16, 2012 01:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready