I was just doing some DB maintenance on my server and in the process there were a few minutes where I mistakenly had nginx running while mysql was down. Unfortunately as I discovered later, fastcgi cache was dutifully caching all the 5XX error pages that were being generated due to inability to connect to the database. So even after I brought mysql back up, nginx kept serving those cached error pages.
I think that the solution is to only cache pages that have a 200 response code and we could do that by changing the fastcgi_cache_valid
line in /etc/conf.d/fastcgi.conf from this:
fastcgi_cache_valid any 1h;
to this:
fastcgi_cache_valid 200 1h;
Before I put an issue and pull request on github, I thought I’d bring it up here and see if anyone knows a reason why that’s a bad idea.