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

蓝咒 提交于 2019-12-31 08:08:19

问题


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.


回答1:


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.




回答2:


From http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

503 (Service unavailable) The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.




回答3:


I'd consider the 503 to be most appropriate, since the 5xx-group is meant for server errors in general.




回答4:


503 Service Unavailable



来源:https://stackoverflow.com/questions/2786595/what-is-the-correct-http-status-code-to-send-when-a-site-is-down-for-maintenance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!