Welcome! Log In Create A New Profile

Advanced

Re: Add header to response before response is cached

Francis Daly
October 10, 2019 04:42AM
On Mon, Oct 07, 2019 at 12:07:29PM -0700, Roger Fischer wrote:

Hi there,

> is there a way in an NGINX HTTP Proxy to add a header to the response before it is cached?
>
> I would like to capture some information from the request and add it to the cached response, so that all clients getting the cached response receive that info.

If you do not find a more direct way (either by config or by coding),
then you could potentially add a new nginx server{} to modify the upstream
response as you want.

That is:

* main nginx does proxy_pass to new nginx, including your extra
information as proxy_set_header values. main nginx does proxy_cache
the response.

* new nginx does proxy_pass to upstream; does not proxy_cache the response;
and does add_header with your extra information so that that extra
information is in the response that goes to main nginx.

"new nginx" can be a server{} that listens on a loopback port, or on a
unix domain socket -- something that the world does not need to access
directly.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Add header to response before response is cached

Roger Fischer October 07, 2019 03:08PM

Re: Add header to response before response is cached

Francis Daly October 10, 2019 04:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 124
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready