-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ratelimits for 1/h appear to allow 2, but no more #76
Comments
What version of django-ratelimit are you using? Can you include the line that's dumping out the contents of the cache, as well as the cache backend? |
Also... because it does a > check, which ISTR is for a reason, though I'm not 100% sure what that reason was. |
Ah, it's coming back to me a little—because this is an atypical way to use ratelimit. When you use the decorator or the mixin, it pre-increments, so if you say Ratelimit may not actually be the right tool here. Remember that it relies on the cache, which is not always reliable, and has staggered windows. If you only want each IP to have one submission per clock hour, just checking to see whether or not there is a saved submission since |
Great thanks for the clarification - I thought I might be missing something - really helpful. |
Using the helper as I don't want to increment all requests, only ones where a successful submission has taken place:
One would expect the above to increment the counter by 1 for every form_valid call, and therefore get ratelimited at the second
dispatch()
. However, this does not happen:The above are the four lines of output from a test, printing the contents of the cache on each subsequent request to the
RegistrationView
. At round one, it adds the cache key, but at round two, the dispatch override returnsFalse
fromis_ratelimited
, even though the rate is1/h
, and then allows a second request to go through, before ratelimiting on the third.Why is this?
The text was updated successfully, but these errors were encountered: