Nginx Caching Error Response Code like 400 , 500 , 503 ,etc

anish10dec nginx-forum at
Sun Aug 7 12:43:04 UTC 2016

Hi Everyone, 

We are using Nginx as Caching Server . 

As per Nginx Documentation by default nginx caches 200, 301 & 302 response
code but we are observing that if Upstream server gives error 400 or 500 or
503, etc , response is getting cached and all other requests for same file
becomes HIT. 

Though if we set proxy_cache_valid specifying response code ( like
proxy_cache_valid 200 15m; ) then also its caching the error response code
but its not caching 301 & 302 in that case. Why the same is not getting
applied for error response code. 

Is this the behaviour of Nginx or bug in Nginx ? We are using 1.4.0 version
of Nginx 

Please help so that error response codes should not get cached as this is
giving the same error response to users who are requesting for the file
though upstream server is healthy and ok to serve the request. 


Posted at Nginx Forum:,268813,268813#msg-268813

More information about the nginx mailing list