Set header $upstream_response_time with proxy_cache directive

Dewangga Bachrul Alam dewanggaba at xtremenitro.org
Fri Nov 4 09:05:30 UTC 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hello!

I have problem how to debugs current response time to upstream, my
configuration is looks likes :

...
upstream upstream_distribution {
        server full-fqdn.tld;
}

# common configuration

        location ~ \.(jpe?g|png|gif|webp)$ {
                proxy_pass      http://upstream_distribution;
                proxy_cache_use_stale error timeout updating http_500
http_502 http_503 http_504;
                proxy_cache_valid 200 302 301 3d;
                proxy_cache     images;
                proxy_cache_valid any 3s;
                proxy_cache_lock on;
                proxy_cache_min_uses 1;
                proxy_ignore_headers Cache-Control Expires;
                proxy_hide_header X-Cache;
                proxy_hide_header Via;
                proxy_hide_header ETag;
                more_set_headers "X-Cache: $upstream_cache_status";
		more_set_headers "X-RTT: $upstream_response_time ms";
        }

# common configuration
...

The problem is, the request was cached by nginx and didn't send
response to upstream, so the response of the header was :

age:94
cache-control:max-age=604800, public
content-length:143862
content-type:image/webp
date:Fri, 04 Nov 2016 09:03:44 GMT
last-modified:Fri, 04 Nov 2016 05:41:55 GMT
x-rtt:ms
server:nginx
status:200
x-cache:HIT

Is it possible to capture upstream_response_time while the content was
cached?

Any hints and helps are appreciated.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQI4BAEBCAAiBQJYHE9VGxxkZXdhbmdnYWJhQHh0cmVtZW5pdHJvLm9yZwAKCRDl
f9IgoCjNcBIAD/wJQfckGIYS4QHTzP+ThjheEcd3bGXRiOjDzp1ixPIUd8WY9f16
ooVGR0ryzkahYSiaJHj7BGnq7otik9S58ZHnHyFjtroTAhcX5YExyskB9IebtWK0
vslk2qq0j59fVmnbhouD7ZI15YNg0YY2lDbiFqmi1KtfkfZJRHkm5rBYWi+MvEsa
vtwKIV9O0nqIH09cVDOWQCJ1pIe5t5lKcQGWTXnVx/HdMOJNFJ5VO4j4Vqyxf829
IJX/nxgGOn46p6djMFx8hVeDK0AxtWjAUUjrUlyaW5OOSkXuuFRs7tdYBXhRZ1W5
cAZQ3XaFpOG8KgLRrI08skIfxIB8v/WCBojj/vulCuKxzGzLb3S8eFOmEcA48ZCV
6CsS/Th0BqYBakiziLawAKuhkCoq+mPETFPmMIzrDtUhMTL0Xqtt8NqFCr4SvlOA
hK7UuRTvCPFnYEpsi4X/fcKxNd0mEC49fvgCHnevANop/6uj+gPFDOlrifzyOiFm
6nCYI5NyXV2eRAAEpiXR5JHLnm4Ch5CDRDLkfMaga25+uAFW0o7PfpG/SEtcMubT
aHOkoUjVAnGyRJm3m94DF4VHqDlUz5N0bpS0QfRnUGzOYCoo3m4gy7ViOQ6UiDuL
OWHKMwKAoVbbIvUpvqwFn2Q46qnIZtDlVtrr7/oNCo//fivpQyLClMGBLg==
=Tyu9
-----END PGP SIGNATURE-----



More information about the nginx mailing list