Is there a better way?

location /assets/ {
if ($uri ~ “^/assets/([a-zA-Z0-9]+)(/.+)”) {
#$1 is hash, $2 is uri
set $memcached_key “$1_$2”;
memcached_pass localhost:11211;

#fallback if not in memcached
error_page 404 =200
/libraries/domain/asset_filter/client/static.php?hash=$1&uri=$2;
}
}

This works but is there a better way?
Sent on the Sprint Now Network from my BlackBerry