Inconsistent variable caching (in SSI or in nginScript)

Maxim Dounin mdounin at mdounin.ru
Tue Oct 10 14:41:57 UTC 2017


Hello!

On Tue, Oct 10, 2017 at 10:22:50AM -0400, Anton Yuzhaninov wrote:

> On 10/09/17 22:15, Anton Yuzhaninov wrote:
> > 
> > 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.
> 
> This problem is not related to nginScript.
> 
> More simple test case:
> 
>     log_format unused '$request_id'; # when this line is commented
> variable is not cached
> 
>     server {
>         listen 8082;
> 
>         location / {
>             ssi on;
>             ssi_types    text/plain;
>             default_type text/plain;
>             return 200 '<!--# echo var="request_id" -->\n<!--# echo
> var="request_id" -->\n';
>         }
>     }
> 
> If $request_id is used only in SSI two different $request_id values are
> shown. If $request_id used anywhere in the config file - variable value
> is cached and two same values are show.

This is a universal problem which is the result of how variable 
caching works: nginx is only able to cache variable which are 
indexed.  So variables which aren't in the configuration but only 
resolved dynamically, as in SSI's echo command, are not cached.

Obviously enough this doesn't looks good, especially taking into 
account the $request_id variable.  Probably a solution would be to 
cache non-indexed variables separately.

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list