Check if your backend server is setting cache headers on errors like Cache-Control / Expires. Nginx by default uses these headers to know if the response should be cached or not. When these headers are not present it uses the configuration done with proxy_cache_valid.
On Sun, Aug 7, 2016 at 9:43 AM, anish10dec <[email protected]> wrote: > 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. > > Regards, > Anish > > Posted at Nginx Forum: https://forum.nginx.org/read. > php?2,268813,268813#msg-268813 > > _______________________________________________ > nginx mailing list > [email protected] > http://mailman.nginx.org/mailman/listinfo/nginx >
_______________________________________________ nginx mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx
