RussellLuo / caddy-ext

Various Caddy v2 extensions (a.k.a. modules).
MIT License
96 stars 21 forks source link

ratelimit: expose rate limit via RateLimit-Policy header #7

Closed derhuerst closed 2 years ago

derhuerst commented 2 years ago

closes #6

RussellLuo commented 2 years ago

@derhuerst Thanks for the PR!

Just out of curiosity, is there any real-world use cases where this single RateLimit-Policy header might help?

derhuerst commented 2 years ago

Just out of curiosity, is there any real-world use cases where this single RateLimit-Policy header might help?

I don't know about any existing production-level systems where RateLimit-Policy is being processed in an automated way. I know that the official GitHub API client uses the GitHub API's x-ratelimit-remaining & x-ratelimit-reset to tell wether & when to retry a request, but that's not RateLimit-Policy.

Personally, I want to adapt my GTFS-Realtime (transit data, encoded as protocol buffers, served via HTTP) client to respect the rate limit of the server, if it has defined one.

derhuerst commented 2 years ago

If I'm not mistaken, the original draft of the rate limiting HTTP headers is from 2019-09-05, so rather new. I hope that more tooling will make use of it in the future.

RussellLuo commented 2 years ago

Personally, I want to adapt my GTFS-Realtime (...) client to respect the rate limit of the server, if it has defined one.

I think this is a valid point, which will potentially promote cooperation and interaction between clients and servers. So let's give this a try and see how it does :)