Nginx – Finding the length of a strength in an nginx.conf file


I am having a problem with my $memcached_keys being too long in my .conf file for nginx. I am using the memcached module but some of my urls are too long. I am in the process of trying to user MD5 hashes of the urls instead but in the meantime I was just wondering if there was a way I could check on the length of a string stored in a variable.


set $memcached_key "byp-$uri";
if ($args) {
    set $memcached_key "byp-$uri?$args";

if (len($memcache_key) < 250) {
     error_page 404 = @cache_miss;
     error_page 502 = @cache_miss;
else {
    pass to @cache_miss;

Best Solution

I'm not positive, but I don't think it can be done within the nginx config language. I suspect it would be documented here if it existed, and I don't see anything.

Related Question