Add Header to cached response?

Maxim Dounin mdounin at
Tue Sep 11 01:04:46 UTC 2018


On Mon, Sep 10, 2018 at 11:06:00AM -0700, Roger Fischer wrote:

> is there a way to add a header to the cached response?
> I have used ngx_http_headers_module’s add_header directive, 
> which adds the header to the response at the time the response 
> is generated.
> What I would like to do is to add a response header at the time 
> when the upstream request is made (reflecting the state of the 
> caching request, not the used-the-cache request).

Cache saves the response as received from the upstream server, 
without any modifications.  If you want to modify it somehow 
before the response is saved into the cache, you can do this 
either on the upstream server itself, or by using additional 

Maxim Dounin

More information about the nginx mailing list