在HTTP响应标头之后重试 - 它会影响任何事情吗? [英] Retry-after HTTP response header - does it affect anything?

查看:396
本文介绍了在HTTP响应标头之后重试 - 它会影响任何事情吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果欲辞让上的网站,服务由于临时过载,HTTP响应 503服务不可用似乎是合适的。该规范中提到发送重发后与头503。

If I want to politely refuse service on a web site due to temporary overload, the HTTP response 503 Service Unavailable seems appropriate. The spec mentions sending a Retry-after header with the 503.

有什么意义吗? Retry-after会影响任何事情吗?浏览器是否会关注它?

Is there any point? Does Retry-after affect anything? Do browsers pay any attention to it?

推荐答案

据我所知,没有浏览器关注标头后重试。代理和缓存可能,但

As far as i'm aware, no browser pays attention to a Retry-after header. Proxies and caches might, but

显然,一些浏览器现在包括对某种程度的支持重发后(尽管支持仍然是最好的)。我并不完全相信在浏览器中这样做的好处;通常,缓存失败被认为是个坏主意。但是如果你知道什么时候你会再次接受请求,告诉客户不会受到伤害。 (如果你比预期更早回来,那么任何真正尊重标题的程序都应该假设 - 然后报告 - 该网站仍在关闭。)

Apparently, some browsers now include some level of support for Retry-After (though support is still iffy at best). I'm not entirely convinced of the benefit of doing so in a browser; generally, it's considered a bad idea to cache failures. But if you know when you'll be accepting requests again, telling the client can't hurt. (If you come back up sooner than expected, though, any program that actually honors the header should assume -- and report -- that the site's still down.)

最明显的好处是,似乎Googlebot(以及可能的其他蜘蛛)会关注标题,如果它在那里,这可以防止它暂时取消索引页面。

The most obvious benefit is, it seems Googlebot (and possibly other spiders) will pay attention to the header if it's there, which can keep it from un-indexing the page for a while.

尽管如此......如果添加起来微不足道,并且您可以对服务的可用时间进行合理准确的估计,那就去吧。不过,我不建议你不要这样做。无论如何它只是建议,并且在那里错误的时间可能会导致更多的问题而不包括标题。

With all that said...if it's trivial to add, and you can come up with a reasonably accurate estimate of when the service will be available, go for it. I wouldn't recommend going out of your way to do it, though. It's only advisory anyway, and putting the wrong time in there could cause more problems than not including the header at all.

这篇关于在HTTP响应标头之后重试 - 它会影响任何事情吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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