Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 1 '12 at 4:05
add comment

1 Answer

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.