Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct HTTP status code to send when a site is down for maintenance?

Is there a HTTP status code to tell Google (and others) to go away, index me again later?

Basically, one that semantically tells clients that the site is down for maintenance?

The ones I have considered are

304 => Not modified 307 => Temporary redirect 410 => Gone 503 => Service Unavailable 

I'm leaning towards the last one, but was just curious as to which one was proper choice.

like image 474
alex Avatar asked May 07 '10 06:05

alex


People also ask

Is the HTTP status code for your website when it's down for maintenance?

The original definition of the 503 status code, according to this RFC, is: The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.

What is 204 status code HTTP?

The HTTP 204 No Content success status response code indicates that a request has succeeded, but that the client doesn't need to navigate away from its current page.

What is HTTP status code1?

We tend to get -1 status codes when there are network issues or connection problems, so we display the user a network problems page in those cases.

What is the meaning of the HTTP status code 201?

2 201 Created. The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the most specific URI for the resource given by a Location header field.


1 Answers

HTTP 503 - Service Unavailable would be the most appropriate.

The Web server (running the Web site) is currently unable to handle the HTTP 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.

This post on the Google Webmaster Central Forum is also relevant:

  • Can I restrict Google from crawling my site on a specific day of the week?

Yes - a 503 is the correct server response for "We're closed". If you substitute a normal HTML page saying "We're closed" and serve a 200 it's very likely to get indexed by Google.

If you give the Googlebot a 503, it will just go away and come back later without indexing what you give it.


UPDATE:

As for the php implementation, you may be interested in checking out the following article:

  • The holding page and the 503 status code

Also notice the retry-after header, where you can specify after how many seconds another request should be re-attempted.

like image 196
Daniel Vassallo Avatar answered Sep 28 '22 15:09

Daniel Vassallo