Memcached not caching

Currently I am testing nginx as a reverse-proxy/load ballencer and the
basic setup is working perfect. But memcached is not caching any content

System: Ubuntu 9.10 server with nginx (from ubuntu repository) and
memcached (from ubuntu repository)

I have three backend server presumed named server1, server2, server 3
and the nginx server is called nginx_test
My nginx.conf:

user www-data;
worker_processes 2;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
use epoll;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
server_tokens off;
upstream cluster {
server server1 ip addr weight=1
server server2 ip addr weight=1;
server server3 ip addr weight=1;
}
server {
listen nginxserver ip addr:80;
server_name nginx_test;
location / {
expires max;
set $memcached_key $uri;
default_type text/html;
memcached_pass localhost:11211;
error_page 404 502 = @cache_miss;
}
location @cache_miss {
proxy_pass http://cluster;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_buffers 8 32k;
}
# requesting nginx status
location /nginx_status {
stub_status on;
access_log off;
allow all;
}
}
#gzip
gzip on;
gzip_http_version 1.0;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_comp_level 5;
gzip_proxied any;
gzip_types text/plain text/css application/javascript
text/javascript text/xml application/x-javascript;
gzip_disable “MSIE [1-6].(?!.*SV1)”;
}

restarting nginx gives no faults and when using the reverse_proxy
everything works but the memcached part is not resulting in faster
loading of the pages. when I telnet into memcached en give the command
stats it shows no cached objects:

Connected to 127.0.0.1.
Escape character is ‘^]’.
stats
STAT pid 11415
STAT uptime 1725
STAT time 1259879709
STAT version 1.2.8
STAT pointer_size 32
STAT rusage_user 0.008000
STAT rusage_system 0.024001
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 5
STAT total_connections 217
STAT connection_structures 8
STAT cmd_flush 0
STAT cmd_get 210
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 210
STAT evictions 0
STAT bytes_read 5947
STAT bytes_written 1588
STAT limit_maxbytes 171966464
STAT threads 5
STAT accepting_conns 1
STAT listen_disabled_num 0

Anny suggestions???

Posted at Nginx Forum:

Hello!

On Thu, Dec 03, 2009 at 05:37:49PM -0500, rhjheins wrote:

Currently I am testing nginx as a reverse-proxy/load ballencer and the basic setup is working perfect. But memcached is not caching any content

nginx doesn’t store anything in memcached,
it just uses memcached as another type of backend.

It’s up to you to store appropriate data…

[…]

STAT cmd_set 0

… and you obviously don’t.

If you want nginx to cache responses from backend - use
proxy_cache instead.

Maxim D.

On Dec 3, 2009, at 2:37 PM, rhjheins wrote:

   }
           location @cache_miss {
                   stub_status     on;
   gzip_proxied    any;

STAT curr_items 0
STAT evictions 0
STAT bytes_read 5947
STAT bytes_written 1588
STAT limit_maxbytes 171966464
STAT threads 5
STAT accepting_conns 1
STAT listen_disabled_num 0

Anny suggestions???

The nginx memcached modules does not actually ever put anything in
the cache for you. Your backend processes are responsible for
populating the cache, nginx will just serve from memcached if an item
already exists at that key.

Cheers-

Ezra Z.
[email protected]

Hi,

Sorry for pumping this -kinda old topic- up, but I’m having the same
issue as the original poster.
After installing memcashed it’s running but not storing or caching
data.

Yes I know nginx doesn’t store anything in memcashed -which is shame-
but what I’m asking for here is how to get memcached to cache and store
data? is there any kind of command or code or something?

I’ve googled for that but I couldn’t find a way to do that.

any help will be appreciated.

Thanks in Advance

P. S.: regarding the proxy_cache in nginx I’m having trouble getting it
work because cookies problem. it cached cookies and that causes a lot of
troubles.

Posted at Nginx Forum: