Can Nginx access memcached to check a specific value to determine where to redirect?

I have middleware in a Django application that redirects mobile clients to a user-configurable mobile domain. This is not easy m.[current domain], as users themselves determine the domain. To save queries, I can save a mapping like this {'www.example.com': 'mobile-version.example.com'}. However, I would like to keep the wsgi server and the full Django stack because they were reached on mobile requests, because this simple logic is the only thing that happens. My thought was that if I could somehow install this logic in Nginx, I would bypass Django altogether, saving some resources. Is it possible? I read where people served entire sites via memcached (it seems like this is a cheaper replacement for just using varnishes), but the methodology seems a bit different.

The logic will look something like this:

$mobile_domain = memcached.get_by_key("mobile_domain_for:" + $current_domain)
IF $mobile_domain:
    redirect $mobile_domain + $path_info + $query_strings
+3
source share
1 answer

It seems that the third - party memc-nginx-module has the ability to search for specific memcached keys.

0
source

All Articles