Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a simple nginx configuration;

  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

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.


pd: you can a sample of the memcached view engine in

share|improve this answer

Your Answer


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.