0

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?

Mark
  • 167
  • 1
  • 6
  • I am following on a similar question. Hope this helps http://forum.nginx.org/read.php?2,227610,227610#msg-227610 –  Jun 17 '12 at 12:16

1 Answers1

1

Sure, you can. Try something like this:

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

 location @fallback {
         internal;
         expires         max;
         proxy_pass      http://127.0.0.1:8080;
         include         /etc/nginx/conf.d/proxy.conf;
         break;
 }
quanta
  • 50,327
  • 19
  • 152
  • 213