Nginx – How to set Nginx ignore Pragma: no-cache

cachenginx

I'm setting up a Nginx server for a cache proxy server.

I've noticed that cache not working when this header is in request:

Pragma: no-cache

Without this header, cache working ok.

Can I make Nginx ignore this header field from client, and caching result. Because I can't change client code easily(need reinstalling lot of devices).

Best Answer

You can specifically instruct nginx to ignore headers with:

proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;

With these directives, an nginx proxy instance will ignore the headers sent by the upstream server and set its own headers for the client (depending on what you specify in the proxy response configuration).