I have nginx with backend nodejs/php-fpm backend how tell the nginx dont cache the response 5xx or 4xx even it's matched for cache parameters.
PHP/Node.js header response long cache time via http headers:
HTTP/1.1 500 Internal Server Error Date: Thu, 09 Mar 2017 09:41:03 GMT Pragma: public Expires: Thu, 09 Mar 2018 09:41:03 GMT Cache-Control: public, max-age=31536000 X-Accel-Expires: Thu, 09 Mar 2018 09:41:03 GMT
Response will cache even the status code is 500 how to prevent it?
nginx config:
location / { proxy_cache_methods GET; proxy_cache_key $request_uri; proxy_cache cache; proxy_cache_valid 200 1h; proxy_cache_use_stale error timeout invalid_header updating; proxy_cache_bypass 0; proxy_no_cache 0; proxy_redirect off; proxy_pass http://node-app; }