我遇到了github api计数问题的请求,该请求针对速率限制产生了304响应
GET /repos/******/***/contents/***?ref=master HTTP/1.1
Host: api.github.com
Connection: keep-alive
Cache-Control: max-age=0
Sec-Fetch-Dest: empty
If-None-Match: W/"b15846765021dc2483e5f3110b53a69f210ececa"
If-Modified-Since: Thu, 19 Mar 2020 01:33:51 GMT
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
Accept: */*
Origin: *******
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: cors
Referer: ******
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
此请求将返回304,不带任何正文,但X-Ratelimit-Remaining减量。
注意:发出条件请求并收到304响应不计入您的速率限制,因此我们建议您尽可能使用它。
我只设置If-None-Match和If-Modified-Since标头,其余的由浏览器设置(使用访存api)
可以通过浏览器复制到https://api.github.com/repos/angular/angular/contents/?ref=master
,并确保禁用了开发人员控制台中的禁用缓存,从而可以使用浏览器进行复制。>
未设置[If-None-Match
和If-Modified-Since
HTTP/1.1 200 OK date: Wed, 01 Apr 2020 12:43:09 GMT content-type: application/json; charset=utf-8 server: GitHub.com status: 200 OK cache-control: public, max-age=60, s-maxage=60 vary: Accept, Accept-Encoding, Accept, X-Requested-With etag: W/"b15846765021dc2483e5f3110b53a69f210ececa" last-modified: Thu, 19 Mar 2020 01:33:51 GMT x-github-media-type: github.v3; format=json access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset access-control-allow-origin: * strict-transport-security: max-age=31536000; includeSubdomains; preload x-frame-options: deny x-content-type-options: nosniff x-xss-protection: 1; mode=block referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin content-security-policy: default-src 'none' content-encoding: gzip X-Ratelimit-Limit: 60 X-Ratelimit-Remaining: 59 X-Ratelimit-Reset: 1585748589 Accept-Ranges: bytes Content-Length: 1696 X-GitHub-Request-Id: B298:74D9:10D7B8:177665:5E848C5D
后跟请求的数据
If-None-Match
和If-Modified-Since
被设置为来自先前请求的etag
和last-modified
标头
HTTP/1.1 304 Not Modified date: Wed, 01 Apr 2020 12:44:51 GMT content-type: application/json; charset=utf-8 server: GitHub.com status: 200 OK cache-control: public, max-age=60, s-maxage=60 vary: Accept, Accept-Encoding, Accept, X-Requested-With etag: W/"b15846765021dc2483e5f3110b53a69f210ececa" last-modified: Thu, 19 Mar 2020 01:33:51 GMT x-github-media-type: github.v3; format=json access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset access-control-allow-origin: * strict-transport-security: max-age=31536000; includeSubdomains; preload x-frame-options: deny x-content-type-options: nosniff x-xss-protection: 1; mode=block referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin content-security-policy: default-src 'none' content-encoding: gzip X-Ratelimit-Limit: 60 X-Ratelimit-Remaining: 58 X-Ratelimit-Reset: 1585748589 X-GitHub-Request-Id: FC10:2036:26E528:346432:5E848CC3
没有数据返回。根据文档,
X-Ratelimit-Remaining
应该停留在59
我的请求是否有问题,或者githubs上的ratelimit是否存在错误?
我遇到了github api计数问题的请求,该请求针对速率限制GET了304响应GET / repos / ****** / *** / contents / ***?ref = master HTTP / 1.1主机:api.github.com连接:...
根据文档
X-Ratelimit-Remaining
应该停留在59