Map a null/missing variable?

OK,

So I’m still working on my caching “issue”, but this is a more general
question, so for the sake of indexing and helping others in the future
with (hopefully) a response…

How do I use a map to map the lack of a variable/header/cookie (NULL?)
to a value? I can’t use “default”, because when there IS a value it
will be a random set of characters.

So that said, if a regex like “.+” would work for “any value” and I use
‘default’ for the NULL, I would try that. :slight_smile:

Thanks in advance,
AJ

On 13 March 2013 18:19, AJ Weber [email protected] wrote:

So that said, if a regex like “.+” would work for “any value” and I use
‘default’ for the NULL, I would try that. :slight_smile:

Have you read the docs? Module ngx_http_map_module
Just make sure you have a recent enough version that support regex in
maps, and it /should/ be pretty obvious.

Jonathan

Jonathan M. // Oxford, London, UK
http://www.jpluscplusm.com/contact.html

On Wednesday 13 March 2013 22:19:50 AJ Weber wrote:

OK,

So I’m still working on my caching “issue”, but this is a more general
question, so for the sake of indexing and helping others in the future
with (hopefully) a response…

How do I use a map to map the lack of a variable/header/cookie (NULL?)
to a value?

You can use ‘’ (empty string) value for that.

wbr, Valentin V. Bartenev


http://nginx.org/en/donation.html

On Wed, Mar 13, 2013 at 02:19:50PM -0400, AJ Weber wrote:

OK,

So I’m still working on my caching “issue”, but this is a more general
question, so for the sake of indexing and helping others in the future
with (hopefully) a response…

How do I use a map to map the lack of a variable/header/cookie (NULL?)
to a value? I can’t use “default”, because when there IS a value it
will be a random set of characters.

You can’t handle the lack of a variable (it’ll cause a syntax
error in configuration). Mapping of an unset variable is easy:

map $http_foo $my_var {
“” unset;
default set;
}

So that said, if a regex like “.+” would work for “any value” and I use
‘default’ for the NULL, I would try that. :slight_smile:

That’s suboptimal.