Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngx.var vs ngx.ctx #1482

Closed
ktalebian opened this issue Feb 26, 2019 · 1 comment
Closed

ngx.var vs ngx.ctx #1482

ktalebian opened this issue Feb 26, 2019 · 1 comment

Comments

@ktalebian
Copy link

What is the different between ngx.var and ngx.ctx? I know var can only hold string values, while ctx can hold any variable, so it seems like it's easier to use ngx.ctx all the time.

Does the ctx persist through internal proxies? Does it have any performance issues? When should one use var or ctx?

@agentzh
Copy link
Member

agentzh commented Feb 26, 2019

@ktalebian Use ngx.ctx wherever you can. ngx.var is much more expensive and is also limited to string values. The latter should only be used to exchange data with other nginx C modules.

BTW, please join the openresty-en mailing list for such general usage questions. This place is reserved for real bug reports and patch submissions. Thanks for
your cooperation! Please see https://openresty.org/en/community.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants