4

I've got a simple nginx configuration;

server{
  servername localhost;
  root /var/www/webroot;

  location / {
    set_md5  $memcached_key $uri;
    index  index.php index.html;
    try_files $uri $uri/ @cache;
  }

  location @cache  {
    memcached_pass localhost:11211;
    default_type text/html;
    error_page 404  @fallback;
  }

  location @fallback{
    try_files $uri $uri/ /index.php?url=$uri&$args;
  }

  location ~ \.php$ {
    fastcgi_param MEM_KEY $memcached_key;
    include /etc/nginx/fastcgi.conf;
    fastcgi_index  index.php;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  }
}

I've got a CakePHP helper that saves the view into memcached using the MEM_KEY parameter. I have tested it and it's working, however, nginx is always going to the @fallback direction. How can I go about troubleshooting this behavior? Would could the problem be?

Tim
  • 175
  • 8
  • Can you use wireshark/tcpdump to capture get and set requests to memcached? I suppose there's something wrong with cakephp. Nginx should work fine, if it have corresponding pages in memcached. – DukeLion Jun 01 '12 at 04:05

1 Answers1

1

Thanks to the comment of DukeLion i could finally found out what whas happening, nginx is doing the get to the memcached server okey, but cakephp is inflecting the key.

Example, i try accesing to /home_page.html

Nginx do a get to the memcache with /home_page.html , dont find it so it loads cakephp, cakephp generate the view and save it in the key _home__page_html

The solution for this was extending the memcached cakephp engine.

Thanks!!!

pd: you can a sample of the memcached view engine in http://andy-gale.com/cakephp-view-memcache.html

Tim
  • 175
  • 8