Welcome! Log In Create A New Profile

Advanced

non-cacheable map directive

Posted by erankor 
non-cacheable map directive
November 27, 2016 09:51AM
Hi,

I have a variable whose value I'd like to split and save the result into another variable. For example, if the value is <part1><part2><part3>, I'd like to capture <part1><part3> into a variable. I found that I can do this using the map directive, with regular expressions and named captures.
Only problem I have is - the variable that I'm splitting is not cacheable - it is changing during the processing of the request. Since the map module does not set 'no_cacheable', the value gets cached after the first evaluation, and subsequent evaluations return the original value.
I manually patched ngx_http_map_module.c to add '| NGX_HTTP_VAR_NOCACHEABLE' in the call to ngx_http_add_variable, and also changed 'var->no_cacheable = 0;' to 'var->no_cacheable = 1;', and this fixed the problem (btw, not sure if I actually needed to change it in all places...).
Would be great if nginx could figure out that the map result depends on a non-cacheable variable, and set the no_cacheable flag appropriately. Alternatively, if that is complicated, adding the ability to manually disable the cache by applying some flag on the map definition in nginx.conf would be awesome as well, e.g.:
map $input_var $output_var nocacheable {
default 0;
"some value" 1;
}

Any feedback will be highly appreciated,

Thank you

Eran
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 183
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready