The upstream server is sending a 404 with a header of Cache-Control: no-cache
.
Due to this, nginx is not caching the request. How can I force it to cache the request?
This caching is only required on the upstream repsponses with a 404 status code.
It can keep the original header and pass this on to the client, but I don't want it sending a 'fresh' request to the page.
I also don't want to remove the header entirely as some of the requests would have a appropriate 'cache control' header set to expire in for example 24h. Hence I can't use proxy_ignore_headers
.
Best Answer
I've been lucky in that I can do this based on the response code (404) and by intercepting the error: