I have a middleware in my Django application that redirects mobile clients to a user-configurable mobile domain. It’s not a simple m.[current domain], since users define the domain themselves. To save queries, I can store a mapping similar to {'www.example.com': 'mobile-version.example.com'}. However, I’d like to save the wsgi server and full Django stack from being reached on mobile requests, because this simple logic is the only thing that is happening. My thought was, if I could place this logic in Nginx somehow, I’d be able to bypass Django altogether, saving some resources. Is this possible? I’ve read where people have served entire sites via memcached (seems like a cheaper replacement for simple Varnish usage), but the methodology seems to be a bit different.
The logic would be something like:
$mobile_domain = memcached.get_by_key("mobile_domain_for:" + $current_domain)
IF $mobile_domain:
redirect $mobile_domain + $path_info + $query_strings
It looks like the third-party memc-nginx-module has the ability to look up specific memcached keys.