发布于 2013-04-16 02:49:31
以下是HTTP API速率限制HTTP响应头的一些示例。取自四个常用的REST API: Github、Vimeo、Twitter和Imgur:
Github速率限制http://developer.github.com/v3/#rate-limiting
#=============================#=============================================#
# HTTP Header # Description #
#=============================#=============================================#
| X-RateLimit-Limit | Request limit per hour |
+-----------------------------+---------------------------------------------+
| X-RateLimit-Remaining | The number of requests left for the time |
| | window |
+-----------------------------+---------------------------------------------+
Vimeo速率限制http://developer.vimeo.com/guidelines/rate-limiting
#=============================#=============================================#
# HTTP Header # Description #
#=============================#=============================================#
| X-RateLimit-Limit | Request limit per day / per 5 minutes |
+-----------------------------+---------------------------------------------+
| X-RateLimit-Remaining | The number of requests left for the time |
| | window |
+-----------------------------+---------------------------------------------+
| X-RateLimit-Reset | The remaining window before the rate limit |
| | resets in UTC epoch seconds |
+-----------------------------+---------------------------------------------+
Twitter REST API速率限制https://dev.twitter.com/docs/rate-limiting/1.1
注:推特使用类似Vimeo的标题,但每个名称中都有另一个破折号。
#=============================#=============================================#
# HTTP Header # Description #
#=============================#=============================================#
| X-Rate-Limit-Limit | The rate limit ceiling for that given |
| | request |
+-----------------------------+---------------------------------------------+
| X-Rate-Limit-Remaining | The number of requests left for the |
| | 15 minute window |
+-----------------------------+---------------------------------------------+
| X-Rate-Limit-Reset | The remaining window before the rate limit |
| | resets in UTC epoch seconds |
+-----------------------------+---------------------------------------------+
Imgur API速率限制http://api.imgur.com/
#=============================#=============================================#
# HTTP Header # Description #
#=============================#=============================================#
| X-RateLimit-UserLimit | Total credits that can be allocated |
+-----------------------------+---------------------------------------------+
| X-RateLimit-UserRemaining | Total credits available |
+-----------------------------+---------------------------------------------+
| X-RateLimit-UserReset | Timestamp (unix epoch) for when the credits |
| | will be reset |
+-----------------------------+---------------------------------------------+
| X-RateLimit-ClientLimit | Total credits that can be allocated for the |
| | application in a day |
+-----------------------------+---------------------------------------------+
| X-RateLimit-ClientRemaining | Total credits remaining for the application |
| | in a day |
+-----------------------------+---------------------------------------------+
发布于 2013-05-24 22:22:49
除了特定于API的报头之外,不要忘记最简单的standard Retry-After
header
服务器发送“Retry After”标头字段,以指示用户代理在发出后续请求之前应该等待多长时间。此字段的值可以是HTTP日期,也可以是接收到响应后延迟的秒数。
该标准在使用503或3xx状态代码时提出了具体的附加建议:
当与503 (服务不可用)响应一起发送时,Retry After指示客户端预期服务不可用的时间。与任何3xx (重定向)响应一起发送时,Retry-After表示在发出重定向请求之前要求用户代理等待的最短时间。
https://stackoverflow.com/questions/16022624
复制相似问题