Forum Moderators: phranque
In the event of a major problem with the database, the site is effectively down. In this instance what is the best response to give to visitors and search engines ?
I am in the process of rewriting the code and considering returning a 404 error if, for example, I cannot connect to the database. Currently I, as many other sites do, simply return a 200 OK and a page which prints the database error message.
I am trying to avoid the situation where I end up with lots of duplicate pages indexed with no content.
Is a 404 the best way to go ?
If your site's maintenance tasks [...] make your content temporarily unavailable, let your visitors know [...] by using the 503 HTTP status code. This will let Google know to check back later, and not index your error page as part of your site's content.
HTTP/1.1: Status Code Definitions:
[w3.org...]
here is the entry for 503 Service Unavailable [w3.org]:
10.5.4 503 Service UnavailableThe server is currently unable to handle the request due to a
temporary overloading or maintenance of the server. The implication
is that this is a temporary condition which will be alleviated after
some delay. If known, the length of the delay MAY be indicated in a
Retry-After header. If no Retry-After is given, the client SHOULD
handle the response as it would for a 500 response.Note: The existence of the 503 status code does not imply that a
server must use it when becoming overloaded. Some servers may wish
to simply refuse the connection.