#reference
http://openresty.org/download/agentzh-nginx-tutorials-en.html
http://blog.sina.com.cn/s/articlelist_1834459124_0_1.html
#set variables
set
a also.
server {
listen 8080;
location /foo {
set
a]”;
}
}
#build-in variables
request_uri(include query string)
args(when you change
args in everywhere)
#variables get handlers & set handlers
in order to save memory, not-indexed variables in Nginx only have one copy , with lots of pointer pointing to them. Every time you need to fetch the variables , you need to parse them from the beginning.
#map for caching
use as cache,run get handlers once . read once ,then the value fixs.
(put outside the server configuration block, that is, it is defined directly within the outermost http configuration block)
map
foo {
default 0;
debug 1;
}
when
foo = 0;when
foo = 1
#lazy evaluation of variables value
assign value when it needs
#special value invaild & not found
>invaild: when a variable is created but no assigned yet
>not found: read an arg which is not existed
>use lua to distinguish
if ngx.var.arg_name == nil then
ngx.say(“name: missing”)
else
ngx.say(“name:[“,ngx.var.arg_name,”]”)
end