[nginx-tests] Tests: index test for flushing non-cacheable varia...

Maxim Dounin mdounin at mdounin.ru
Sat Jul 18 17:13:27 UTC 2026


details:   http://freenginx.org/hg/nginx-tests/rev/bd857e1a45f8
branches:  
changeset: 2079:bd857e1a45f8
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Sat Jul 18 20:11:10 2026 +0300
description:
Tests: index test for flushing non-cacheable variables.

diffstat:

 index.t |  25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diffs (67 lines):

diff --git a/index.t b/index.t
--- a/index.t
+++ b/index.t
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 
+# (C) Maxim Dounin
 # (C) Sergey Kandaurov
 # (C) Nginx, Inc.
 
@@ -22,7 +23,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http rewrite map/)->plan(16)
+my $t = Test::Nginx->new()->has(qw/http rewrite map/)->plan(17)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -43,6 +44,11 @@ http {
        ~(?<shrink>) "";
     }
 
+    map $index $map_volatile {
+       volatile;
+       ~^ $index;
+    }
+
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
@@ -99,11 +105,20 @@ http {
             alias %%TESTDIR%%/;
             index index.$capture.$map_capture /index.html;
         }
+
         location /shrink/ {
             alias %%TESTDIR%%/;
             set $shrink "some-long-variable-value";
             index index$shrink$map_shrink.html /index.html;
         }
+
+        location /volatile/ {
+            alias %%TESTDIR%%/;
+            set $index notfound.html;
+            set $dummy $map_volatile;
+            set $index index.html;
+            index $map_volatile;
+        }
     }
 }
 
@@ -156,6 +171,14 @@ like(http_get('/shrink/'), qr!X-URI: /sh
 
 }
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.4');
+
+like(http_get('/volatile/'), qr!X-URI: /volatile/index.html\x0d?($).*body!ms,
+	'index flushes non-cacheable variables');
+
+}
+
 $t->stop();
 
 like($t->read_file('log_not_found.log'), qr/error/, 'log_not_found');


More information about the nginx-devel mailing list