Retry-after HTTP 响应标头 - 它会影响什么吗? [英] Retry-after HTTP response header - does it affect anything?

查看:29
本文介绍了Retry-after HTTP 响应标头 - 它会影响什么吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我因临时超载而想礼貌地拒绝网站上的服务,HTTP 响应 503 Service Unavailable 似乎很合适.该规范提到发送带有 Retry-after 标头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?

推荐答案

据我所知,没有浏览器会关注 Retry-after 标头.代理和缓存可能,但是

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

显然,一些浏览器现在包含了对 Retry-After 的某种程度的支持(尽管支持最多仍然是不确定的).我并不完全相信在浏览器中这样做的好处.通常,缓存故障被认为是一个坏主意.但是,如果您知道什么时候会再次接受请求,那么告诉客户不会有什么坏处.(但是,如果您恢复得比预期的要早,那么任何实际支持标头的程序都应该假设并报告该站点仍然处于关闭状态.)

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.

这篇关于Retry-after HTTP 响应标头 - 它会影响什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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