filter to modify upstream response before it is cached

Francis Daly francis at
Mon Jan 13 10:03:09 UTC 2020

On Fri, Jan 10, 2020 at 04:57:32PM -0800, Roger Fischer wrote:

Hi there,

> is there a hook into the nginx processing to modify the response body (and headers) before they are cached when using with proxy_pass?

I don't know if there is such a hook; but I do know that you can introduce
another nginx-step to achieve the same end result.

That is: right now you have something like:

  nginx: proxy_pass with cache -> upstream

Instead you can have

  nginx: proxy_pass with cache -> nginx: proxy_pass with body filter
  -> upstream

so that the output of the one run of your body filter is cached by the
first nginx.

Francis Daly        francis at

More information about the nginx mailing list