Please Help With Memcached Setup

Hi

I am running Nginx 0.7.67 with the Memc and Echo 3rd party modules in
trying to follow
http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html#35.

I want to serve some static files from memcached and am trying a self
updating setup as in the following pseudocode:

if request for specified files {
  if in memcache {
    serve from memcache
  } else {
    try to put into memcache
    try to serve from memcache
    if unable to serve from memcache {
      proxy to apache
    }
  }
}

I will actually prefer to do this…:

if request for specified files {
  if in memcache {
    serve from memcache
  } else {
    try to put into memcache
    try to serve from memcache
    if unable to serve from memcache {
      [b]try to serve from disk[/b]
    }
    if unable to serve from memcache {
      proxy to apache
    }
  }
}

…but started to get too complicated and I can get to that after I
manage to get it working in the first place

The relevant portion of my conf file is…:

location ~* ^.+\.(jpe?g|gif|png|css|js|ico|swf|dat|xml)$ {
  set $memc_cmd 'get';
  set $memc_key '$scheme://$host$request_uri';
  memc_pass 127.0.0.1:11211;
  add_header X-Memc-Flags $memc_flags;
  error_page 404 = @add-and-retry;
  error_page 502 = @fallback;
  log_not_found  off;
  access_log /dev/null main;
}
location @add-and-retry {
  echo_location
/memc?cmd=add&key='$scheme://$host$request_uri'&val=$document_root$uri&exptime=0;
  echo_location /memc?cmd=get&key='$scheme://$host$request_uri';
}
location /memc {
  internal;
  set $memc_cmd $arg_cmd;
  set $memc_key $arg_key;
  set $memc_value $arg_val;
  set $memc_exptime $arg_exptime;
  memc_pass 127.0.0.1:11211;
  error_page 404 502 = @fallback;
}
location @fallback {
  log_not_found  off;
  access_log /dev/null main;
  proxy_pass http://127.0.0.1:8080;
  # proxy params
  include /etc/nginx/proxy.default;
}

…but these files do not get served at all. I.E. it doesn’t even get
passed to apache.

Please help unravel or suggest alternative(s).

Thanks.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,117833,117833#msg-117833

My pseudo code should have been…:

if request for specified files {
  if file in memcache {
    serve file from memcache
  [color=#FF0033][b]} else if memcache error {
      proxy to apache[/b][/color]
  } else {
    try to put into memcache
    try to serve from memcache
    if unable to serve from memcache {
      proxy to apache
    }
  }
}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,117833,117837#msg-117837

On Mon, Aug 9, 2010 at 9:43 PM, Dayo [email protected] wrote:

Hi

I am running Nginx 0.7.67 with the Memc and Echo 3rd party modules in
trying to follow
http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html#35.

I want to serve some static files from memcached and am trying a self
updating setup as in the following pseudocode:

This is a FAQ regarding my ngx_memc module :slight_smile: And this can be done by
combining the ngx_memc and ngx_srcache modules:

http://github.com/agentzh/srcache-nginx-module

The only caveat is that ngx_srcache does not cache response headers
(yet), so it’s necessary to use the , <default_type> and
<add_header> directives to explicitly set the Content-Type header and
etc. It’s probably a bad idea to combine this module with ngx_proxy
which usually returns varying response headers :slight_smile:

Support for response header caching in ngx_srcache is a TODO and
patches for this will be highly appreciated :slight_smile:

Cheers,
-agentzh

Thanks for the response.

This was experimental to see if this self updating setup can easily be
done but don’t want to go too bleeding edge so will leave it for now.

Cheers

Dayo

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,117833,118167#msg-118167

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs