filter to modify upstream response before it is cached

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

filter to modify upstream response before it is cached

Roger Fischer
Hello,

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 am aware of the body filters (http://nginx.org/en/docs/dev/development_guide.html#http_body_filters), running before the response is delivered to the client. But I would prefer to run the filter just once, when the upstream response is cached.

I am assuming, if nginx does not offer such a hook, OpenResty will not be of any help either.

Thanks…

Roger


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: filter to modify upstream response before it is cached

Francis Daly
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.

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx