Nginx caching 500 Internal Server Error response

TheMask nginx-forum at forum.nginx.org
Thu Jun 24 19:36:42 UTC 2021


Hi everyone,
We are using Nginx as reverse proxy.
>From last 8-9months we are facing one issue in which nginx 500 response
spike obseved. And we didnt see any call to upstream. It seems like Nginx
caches the 500 response and that us served back to user.
We have to restart the Nginx every time when issue occurred.

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.

Please advise to resolve this issue.

Thanks,

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,291914,291914#msg-291914



More information about the nginx mailing list