Abstract behavior of nginx

Maxim Dounin mdounin at mdounin.ru
Mon Nov 25 13:31:48 UTC 2013


Hello!

On Fri, Nov 22, 2013 at 02:47:23PM +0100, Pomorski Jarosław wrote:

> Hi,
> 
> I can't understand behavior of nginx.
> Version 1.2.1 on Debian Wheezy from official repository. I send 
> requests to cdn.some_domain.pl server, and in log 
> /var/log/nginx/cdn.some_domain.pl/test.log I see:
> 
> image/gif:1
> image/png:1
> image/png:1
> image/gif:1
> image/png:1
> image/gif:1
> 
> It is correct. If I remove hash sign in 3 last line of 
> configuration file, nginx puts to 
> /var/log/nginx/cdn.some_domain.pl/test.log below entries:
> 
> -:0
> -:0
> -:0
> -:0
> -:0
> -:0
> 
> I don't understand, why in this configuration, value of 
> $sent_http_content_type variable is empty.

[...]

>                 map $sent_http_content_type $cdn {
>                                default         0;
>                                text/css        1;
>                                text/javascript 1;
>                                image/x-icon    1;
>                                image/gif       1;
>                                image/jpeg      1;
>                                image/png       1;
>                 }

[...]

> #             if ($cdn) {
> #                             return 404;
> #             }

The "if ($cdn)" is evaluated while processing rewrite rules, and 
at this point value of $sent_http_content_type isn't yet known 
(because response isn't sent).  But due to this evaluation 
calculated values of the $sent_http_content_type and $cdn 
variables are cached, and not re-evaluated again later.

That is, what you see in logs is a value of the 
$sent_http_content_type variable at the time the variable was 
evaluated for the first time during request processing.

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list