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

Wandenberg Peixoto wandenberg at gmail.com
Sun Aug 7 13:19:30 UTC 2016


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 <nginx-forum at forum.nginx.org>
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
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160807/bd1cacbd/attachment.html>


More information about the nginx mailing list