njs: how to define a global variable

Dmitry Volyntsev xeioex at nginx.com
Mon Jun 3 17:42:31 UTC 2019



On 29.05.2019 20:02, guy1976 wrote:
> hi
> 
> is it possible to define a global variable that will be persist  for
> different requests?


Hi Guy,

Currently it is not possible as all njs VM are short-lived (a VM per 
request).
If performance is not a serious issue you can use FS API (see 
http://nginx.org/en/docs/njs/reference.html#njs_api_fs)


> 
> thank you,
> Guy.
> 
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,284350,284350#msg-284350
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
> 


More information about the nginx mailing list