Can Nginx only cache reponse body while excluding some response headers?

Francis Daly francis at
Fri Dec 7 22:23:54 UTC 2018

On Sun, Dec 02, 2018 at 06:29:33PM +0800, yf chu wrote:

Hi there,

> We all know that the cache feature in Nginx will cache all response content generated by upstream server. But I wonder whether there is a solution that only the response body is cached by Nginx while some response headers should not be cached and should be sent to client directly .

I'm afraid I don't understand what exactly you are asking.

Could you give more details, or an example?

Such as:

request from client to nginx; not in cache, so nginx asks upstream which
returns headers+body. What do you want nginx to store in the cache,
and what should nginx send to the client?

same request from client to nginx; it is in the cache. What should nginx
send to the client?

The answer to that might make your question clearer.


Francis Daly        francis at

More information about the nginx mailing list