Inconsistent variable caching (in SSI or in nginScript)

Anton Yuzhaninov citrin at citrin.ru
Tue Oct 10 02:15:49 UTC 2017


Hello,

I've encountered a bug (or unexpected and not well documented feature)
in SSI (ngx_http_ssi_module) or in nginScript (ngx_http_js_module).

If a variable, which set via js_set is used only in SSI it is not cached
and nginScript function called several times for one HTTP request.

If the same variable is used anywhere in a config file, then a variable
value is cached (for a request).

Test config:

js_include /home/citrin/w/nginx/random.js;

js_set $random_int randomInt;

server {
        listen 8081;

        location / {
                ssi on;
                ssi_types    text/plain;
                default_type text/plain;
                return 200 '<!--# echo var="random_int" -->\n<!--# echo
var="random_int" -->\n';
        }

        location /unrelated {
                add_header X-rnd $random_int;
        }
}


With a config above I see the same random number printed twice (as
expected).

But when an add_header directive is commented out I see two different
random numbers (and this change is not expected).

nginx version: nginx/1.12.1
nginx-module-njs 0.1.10

-- 
Best Regards,
Anton Yuzhaninov


More information about the nginx mailing list