I am using nginx for reverse proxy with caching. And I have a backend that sometimes returns 200 HTTP code for failed requests, with just an empty set for a body. I'd like to configure nginx in a way that would prevent storing of such responses.
I tried setting no_cache like this:
if ($upstream_http_content_length = "2") { set $nocache 1; } # empty response
proxy_no_cache $nocache;
But that doesn't work. What are my other options (besides fixing backend to behave properly)?
0 Answers