[nginx-announce] njs-0.8.1

Dmitry Volyntsev xeioex at nginx.com
Tue Sep 12 23:08:59 UTC 2023


I'm glad to announce a new release of NGINX JavaScript module (njs).

Notable new features:
- Periodic code execution:
js_periodic direcrive specifies a content handler to run at regular 
The handler receives a session object as its first argument, it also has 
to global objects such as ngx.

: example.conf:
:  location @periodics {
:    # to be run at 1 minute intervals in worker process 0
:    js_periodic main.handler interval=60s;
:    # to be run at 1 minute intervals in all worker processes
:    js_periodic main.handler interval=60s worker_affinity=all;
:    # to be run at 1 minute intervals in worker processes 1 and 3
:    js_periodic main.handler interval=60s worker_affinity=0101;
:    resolver;
:    js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;
:  }
: example.js:
:  async function handler(s) {
:    let reply = async ngx.fetch('https://nginx.org/en/docs/njs/');
:    let body = async reply.text();
:    ngx.log(ngx.INFO, body);
:  }

Learn more about njs:

- Overview and introduction:
- NGINX JavaScript in Your Web Server Configuration:
- Extending NGINX with Custom Code:
- Using node modules with njs:
- Writing njs code using TypeScript definition files:

Feel free to try it and give us feedback on:

- Github:
- Mailing list:

Additional examples and howtos can be found here:

- Github:

Changes with njs 0.8.1                                       12 Sep 2023

     nginx modules:

     *) Feature: introduced js_periodic directive.
         The directive specifies a JS handler to run at regular intervals.

     *) Feature: implemented items() method for a shared dictionary.
        The method returns all the non-expired key-value pairs.

     *) Bugfix: fixed size() and keys() methods of a shared dictionary.

     *) Bugfix: fixed erroneous exception in r.internalRedirect()
        introduced in 0.8.0.


     *) Bugfix: fixed incorrect order of keys in

More information about the nginx-announce mailing list