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?
Asked
Active
Viewed 677 times
1 Answers
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;
}
![](../../users/profiles/59925.webp)
quanta
- 50,327
- 19
- 152
- 213