You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ngx.var.VAR needs to do a metatable index function call, and then do an FFI c function call to get the HTTP header, This function can get one particular HTTP header, but it needs another lua index metastable, which may be some performance regression if we do this very frequency.
ngx.req.get_headers can get all HTTP headers, It's a pure FFI function, so there is no need to do other metastable index function calls. But it can only return all HTTP headers, So it may need many memory or CPU time if the caller does not want to get all HTTP headers.
So if you want to get all HTTP Header in the current request, you may need to use ngx.req.get_headers, it's better to use ngx.var.VAR if you just want to get a particular HTTP header.
https://github.com/openresty/lua-nginx-module#ngxvarvariable
vs
https://github.com/openresty/lua-nginx-module#ngxreqget_headers
This might need a bit more explanation on when to use what, or why ngx.req.get_headers is more preferable considering ngx.var is to be avoided.
The text was updated successfully, but these errors were encountered: