New worker Rate limit

After rare limiting a user, does the requests from him still invoke the worker or not ?
3 Replies
Chaika
Chaika3mo ago
If you're using the rate limiting binding, yes. If you're using WAF Rate Limiting/configured in the dashboard under Security, no
Sb
SbOP3mo ago
Okay. In binding, even after limiting for saay 60s, it will invoke the worker in that 60s (with 429) ??? Or it will only be invoked when the user is under the limit and at the req on which the user gets rate limited ?
Chaika
Chaika3mo ago
The worker will always be invoked with the binding rate limiting. Your worker logic has to be ran to return the response on rate limiting,
const { success } = await env.MY_RATE_LIMITER.limit({ key: pathname })
if (!success) {
return new Response(`429 Failure – rate limit exceeded for ${pathname}`, { status: 429 })
}
const { success } = await env.MY_RATE_LIMITER.limit({ key: pathname })
if (!success) {
return new Response(`429 Failure – rate limit exceeded for ${pathname}`, { status: 429 })
}

Did you find this page helpful?