<div dir="ltr">Check if your backend server is setting cache headers on errors like Cache-Control / Expires.<div>Nginx by default uses these headers to know if the response should be cached or not.</div><div>When these headers are not present it uses the configuration done with proxy_cache_valid.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 7, 2016 at 9:43 AM, anish10dec <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Everyone,<br>
<br>
We are using Nginx as Caching Server .<br>
<br>
As per Nginx Documentation by default nginx caches 200, 301 & 302 response<br>
code but we are observing that if Upstream server gives error 400 or 500 or<br>
503, etc , response is getting cached and all other requests for same file<br>
becomes HIT.<br>
<br>
Though if we set proxy_cache_valid specifying response code ( like<br>
proxy_cache_valid 200 15m; ) then also its caching the error response code<br>
but its not caching 301 & 302 in that case. Why the same is not getting<br>
applied for error response code.<br>
<br>
Is this the behaviour of Nginx or bug in Nginx ? We are using 1.4.0 version<br>
of Nginx<br>
<br>
Please help so that error response codes should not get cached as this is<br>
giving the same error response to users who are requesting for the file<br>
though upstream server is healthy and ok to serve the request.<br>
<br>
Regards,<br>
Anish<br>
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,268813,268813#msg-268813" rel="noreferrer" target="_blank">https://forum.nginx.org/read.<wbr>php?2,268813,268813#msg-268813</a><br>
<br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</blockquote></div><br></div>