当网站停机维护时,要发送的正确HTTP状态代码是什么? [英] What is the correct HTTP status code to send when a site is down for maintenance?

查看:513
本文介绍了当网站停机维护时,要发送的正确HTTP状态代码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有HTTP状态代码告诉Google(及其他人)消失,稍后再次为我索引

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?

我考虑过的是

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.

推荐答案

HTTP 503 - 服务不可用将是最合适的。


由于服务器的临时过载或维护,Web服务器(运行Web站点)当前无法处理HTTP请求。这意味着这是一个临时条件,经过一段时间的延迟后会得到缓解。

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.

Google网站管理员中心论坛上的这篇文章也是相关:

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?

是 - 503是我们关闭的正确服务器响应。如果你用普通的HTML页面替换我们已关闭并提供200,则很可能会被Google编入索引。

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.

如果你给Googlebot一个503,它会消失并在以后回来而不会为你提供的内容编制索引。

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






更新:

至于php实现,您可能有兴趣查看以下文章:

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.

这篇关于当网站停机维护时,要发送的正确HTTP状态代码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆