Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 want to use nginx with the memcache module to check my memcache server first then if the key is not found then to fallback to my upstream servers. I see lots of examples of proxing to multiple upstream servers (e.g. round robin), but can I fallback in this manner from memcache misses?

share|improve this question
I am following on a similar question. Hope this helps,227610,227610#msg-227610 – user124969 Jun 17 '12 at 12:16
up vote 1 down vote accepted

Sure, you can. Try something like this:

 location ~* ^.+.(css|js|jpg|png|gif|ico)$ {
        expires                 max;
        set $memcached_key      "$scheme://$host$request_uri";
        error_page              404 = @fallback;

 location @fallback {
         expires         max;
         include         /etc/nginx/conf.d/proxy.conf;
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.