Drupal currently returns a 503 HTTP status when the site is in maintenance mode. I believe this is based on a misunderstanding of HTTP. Maintenance mode in Drupal is not a server error at all (which is what 5xx error codes are supposed to indicate) - it is an explicit decision by the administrator of an application on the server to restrict how users of the application may interact with it. 5xx errors should be used when there's an issue with the web server itself.

Per RFC 2616:

The 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.

The first sentence is the money quote. In the case of maintenance mode, I believe we should still simply return a 200 status with the maintenance message.

Comments

rszrama created an issue. See original summary.

dawehner’s picture

Interesting. Should we maybe specify a retry after 1 minute or so?

rszrama’s picture

I honestly just think we shouldn't be using a 5xx at all, as technically speaking, the server and application are performing exactly as expected. I didn't fully research how browsers support Retry-After, but I think there are enough varied reasons for administrators to put sites in maintenance mode that it's probably not worth pursuing.

dawehner’s picture

I could agree, becase it is an issue because some reverse proxies treat 500 as totally broken site.

imrancluster’s picture

Last night I spent 2 hours to find out why show the 503 Service unavailable message for maintenance mode. As a new I didn't find out the issue :(

dawehner’s picture

At least google itself recommends a 503 as well, see https://googlewebmastercentral.blogspot.de/2011/01/how-to-deal-with-plan...

rszrama’s picture

Oh! Interesting find - hadn't thought about extended downtime and its impact on crawlers.

dawehner’s picture

@rszrama So won't fix?

rszrama’s picture

I don't know - guess it's worth looking into further. That article is 5 years old, though I suppose they wouldn't have had any reason to change their approach.

It still feels like Google is asking webmasters to abuse the code, but maybe we need to repurpose the issue to support a Retry-After header if we're going to use the code?

rszrama’s picture

(And I suppose at the very least we can add a comment to the maintenance mode subscriber to satisfy future pedants like me. ; )

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Status: Active » Fixed

#2653318: While in maintenance mode, REST routes respond with HTML instead of XML/JSON/… assumes also we use 503 status codes, especially for REST requests. I think given that we expose that more and more, not changing it seems the only reasonable approach.

rszrama’s picture

Status: Fixed » Closed (works as designed)

+1

mxr576’s picture

FTR, I have opened this as a follow up, hopefully this idea is more welcomed than it was before: #3347601: Add Retry-After header to HTML maintenance mode responses