Response header from fcgi server

Hi,

PHP-application sends response with HTTP header X-Language and I need
pass this to nginx.
With Firebug I see this header, but variable $http_x_language or
$sent_http_x_language is empty.

What I am doing wrong?

— Original message —
From: “wishmaster” [email protected]
Date: 17 September 2014, 08:49:51

Hi,

PHP-application sends response with HTTP header X-Language and I need pass this
to nginx.
With Firebug I see this header, but variable $http_x_language or
$sent_http_x_language is empty.

What I am doing wrong?

Hmm… Interesting.
I have changed header from “X-Language” to something like “Currlang”
and now I see variable $sent_http_currlang.

On Wed, Sep 17, 2014 at 08:49:36AM +0300, wishmaster wrote:

Hi there,

PHP-application sends response with HTTP header X-Language and I need pass this
to nginx.
With Firebug I see this header, but variable $http_x_language or
$sent_http_x_language is empty.

What I am doing wrong?

$http_x_language is a request header field – what the client sent
to nginx.

$sent_http_x_language is a response header field – what nginx sent to
the client.

$upstream_http_x_language would be what an upstream sent to nginx.

What do you do? What do you see? What do you expect to see?

f

Francis D. [email protected]

— Original message —
From: “wishmaster” [email protected]
Date: 17 September 2014, 10:21:03

$sent_http_x_language is a response header field – what nginx sent to

My problem is still actual.
I am attempting to use http header from fastcgi server as part of
cache key.
$upstream_http_x_language contains value, but empty in cache key

Part of cached page:

KEY: httpGETexample.comfoto-video-audio/videoUAH
▒Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Last-Modified: Wed, 17 Sep 2014 13:59:43 GMT
Cache-Control: private
X-Language: uk
X-Accel-Buffering: yes

key must be
httpGETexample.comfoto-video-audio/videoukUAH


w

— Original message —
From: “Francis D.” [email protected]
Date: 17 September 2014, 10:06:47

to nginx.

$sent_http_x_language is a response header field – what nginx sent to
the client.

$upstream_http_x_language would be what an upstream sent to nginx.

What do you do? What do you see? What do you expect to see?

Oh Francis, you help save me a lot of time as always, thanks.
I did not know about $upstream_* variable

Without fastcgi caching, $sent_http_x_language is not empty, but if
chaching is “ON”, $sent_http_x_language variable is empty. But
$upstream_* contain expected data.

Thanks a lot!


Cheers,
Vitaliy

On Wed, Sep 17, 2014 at 05:22:14PM +0300, wishmaster wrote:

Hi there,

My problem is still actual.
I am attempting to use http header from fastcgi server as part of cache key.
$upstream_http_x_language contains value, but empty in cache key

How should that work?

A request comes in to nginx.

nginx creates the cache key to see if it should serve the request from
cache, or should pass the request along to upstream and store the
response
in cache.

If you try to put something into your cache key that nginx can only know
about after the request has been passed upstream, you are going to have
a problem.

Part of cached page:

KEY: httpGETexample.comfoto-video-audio/videoUAH

key must be
httpGETexample.comfoto-video-audio/videoukUAH

Why does this matter?

What two requests would lead to upstream sending content with a
different
language? Use whatever is different in those requests in your cache key.

f

Francis D. [email protected]

On Wed, Sep 17, 2014 at 05:42:18PM +0300, wishmaster wrote:

What two requests would lead to upstream sending content with a different
language? Use whatever is different in those requests in your cache key.

At this time cache key uses $cookie_language, this works as expected. But I do
not understand why with $http_ or $upstream_ does not work.

$http_ comes from the client, so should work.

$upstream_ is empty until after upstream has responded, which is too
late to be used in a cache key.

f

Francis D. [email protected]

— Original message —
From: “Francis D.” [email protected]
Date: 17 September 2014, 17:29:43

A request comes in to nginx.

nginx creates the cache key to see if it should serve the request from
cache, or should pass the request along to upstream and store the response
in cache.

If you try to put something into your cache key that nginx can only know
about after the request has been passed upstream, you are going to have
a problem.

I know how this works.

What two requests would lead to upstream sending content with a different
language? Use whatever is different in those requests in your cache key.

At this time cache key uses $cookie_language, this works as expected.
But I do not understand why with $http_ or $upstream_ does not work.