memcache_pass not allowed in if block?

John Luxford john.luxford at
Sun Mar 22 02:34:48 MSK 2009


I would like to check for a session cookie before using
memcached_pass, since authenticated users in our site would be seeing
more dynamic content on the same pages that anonymous users would see
cached copies of. But when I do something like this:

if ($http_cookie != "session_id=") {
    set $memcached_key $uri;
    memcached_pass 11211;
    default_type text/html;

I get the following error:

2009/03/21 18:20:27 [emerg] 78240#0: "memcached_pass" directive is not
allowed here in /opt/local/etc/nginx/sites.conf:29

I see that fastcgi_pass can be used in if blocks, so why can't
memcached_pass too? And is there any workaround to this? I'm just
getting up to speed on configuring nginx, but can't seem to find
another way of going about this.



More information about the nginx mailing list