[nginx-announce] njs-0.8.0

Dmitry Volyntsev xeioex at nginx.com
Thu Jul 6 22:23:22 UTC 2023


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

Notable new features:
- shared dictionaries:
Shared dictionary keeps the key-value pairs shared between worker
processes. This allows to cache data in memory and share it between

: example.conf:
:   # Creates a 1Mb dictionary with string values,
:   # removes key-value pairs after 60 seconds of inactivity:
:   js_shared_dict_zone zone=foo:1M timeout=60s;
:   # Creates a 512Kb dictionary with string values,
:   # forcibly removes oldest key-value pairs when the zone is overflowed:
:   js_shared_dict_zone zone=bar:512K timeout=30s evict;
:   # Creates a 32Kb permanent dictionary with numeric values:
:   js_shared_dict_zone zone=num:32k type=number;
: example.js:
:    function get(r) {
:        r.return(200, ngx.shared.foo.get(r.args.key));
:    }
:    function set(r) {
:        r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));
:    }
:    function delete(r) {
:        r.return(200, ngx.shared.bar.delete(r.args.key));
:    }
:    function increment(r) {
:        r.return(200, ngx.shared.num.incr(r.args.key, 2));
:    }

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.0                                        6 Jul 2023

     nginx modules:

     *) Change: removed special treatment of forbidden headers in Fetch API
        introduced in 0.7.10.

     *) Change: removed deprecated since 0.5.0 r.requestBody and
        r.responseBody in HTTP module.

     *) Change: throwing an exception in r.internalRedirect() while
        filtering in HTTP module.

     *) Feature: introduced global nginx properties.
         ngx.build - an optional nginx build name, corresponds to
         --build=name argument of configure script, by default is "".
         ngx.conf_file_path - the file path to current nginx configuration
         ngx.error_log_path - the file path to current error log file.
         ngx.prefix - the directory that keeps server files.
         ngx.version - the nginx version as a string, for example: "1.25.0".
         ngx.version_number - the nginx version as a number, for example:
         ngx.worker_id - corresponds to an nginx internal worker id.
            The value is between 0 and worker_processes - 1.

     *) Feature: introduced js_shared_dict_zone directive.
         The directive allows to declare a dictionary that is shared 
among the
         working processes.

     *) Improvement: added compile-time options to disable njs modules.
         For example to disable libxslt related code:
         NJS_LIBXSLT=NO ./configure  .. --add-module=/path/to/njs/module

     *) Bugfix: fixed r.status setter when filtering in HTTP module.

     *) Bugfix: fixed setting of Location header in HTTP module.


     *) Change: native methods are provided with retval argument.
        This change breaks compatibility with C extension for njs
        requiring to modify the code.

     *) Change: non-compliant deprecated String methods were removed.
         The following methods were removed: String.bytesFrom(),
         String.prototype.fromBytes(), String.prototype.fromUTF8(),
         String.prototype.toBytes(), String.prototype.toUTF8(),

     *) Change: removed support for building with GNU readline.

     *) Feature: added Array.from(), Array.prototype.toSorted(),
         Array.prototype.toSpliced(), Array.prototype.toReversed().

     *) Feature: added %TypedArray%.prototype.toSorted(),

     *) Feature: added CryptoKey properties in WebCrypto.
         The following properties for CryptoKey were added:
         algorithm, extractable, type, usages.

     *) Bugfix: fixed retval of crypto.getRandomValues().

     *) Bugfix: fixed evaluation of computed property names with function

     *) Bugfix: fixed implicit name for a function expression declared in

     *) Bugfix: fixed parsing of for-in loops.

     *) Bugfix: fixed Date.parse() with ISO-8601 format and UTC time

More information about the nginx-announce mailing list