[PATCH] Variables: honor no_cacheable for not_found variables

Maxim Dounin mdounin at mdounin.ru
Sat Feb 20 05:54:16 MSK 2010

# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1266634085 -10800
# Node ID dd5526e935d256a3f8c55e5ffde9890d1e1e4a8d
# Parent  0f0a551e29c08abf4a01d255be44e421d581f7b7
Variables: honor no_cacheable for not_found variables.

Variables with not_found flag set follow the same rules as ones with valid
flag set.  Make sure ngx_http_get_flushed_variable() will flush non-cacheable
variables with not_found flag set.

This fixes at least one known problem with $args not available in subrequest
(with args) when there were no args in main request and $args variable was
queried in main request (reported by Laurence Rowe aka elro on irc).

Also eliminate unneeded call to ngx_http_get_indexed_variable() in cacheable
case (as it will return cached value anyway).

diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -426,7 +426,7 @@ ngx_http_get_flushed_variable(ngx_http_r
     v = &r->variables[index];
-    if (v->valid) {
+    if (v->valid || v->not_found) {
         if (!v->no_cacheable) {
             return v;

More information about the nginx-devel mailing list