feat: rate-limit good bots via object cache, add curl/ClaudeBot tiers, whitelist cache warmer
This commit is contained in:
@@ -119,10 +119,10 @@ class ITK_Bot_Blocker {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sliding window: track hits per bot per minute using transients.
|
||||
// Sliding window: track hits per bot per minute using object cache (no DB writes).
|
||||
$window = (int)(time() / 60); // 1-minute window
|
||||
$tk_key = 'itk_rl_' . md5($name) . '_' . $window;
|
||||
$count = (int)get_transient($tk_key);
|
||||
$count = (int)wp_cache_get($tk_key, 'itk_rl');
|
||||
|
||||
if ($count >= $limit) {
|
||||
// Over the limit – log and send 429.
|
||||
@@ -147,7 +147,7 @@ class ITK_Bot_Blocker {
|
||||
}
|
||||
|
||||
// Under the limit – increment counter and allow through.
|
||||
set_transient($tk_key, $count + 1, 120);
|
||||
wp_cache_set($tk_key, $count + 1, 'itk_rl', 120);
|
||||
}
|
||||
|
||||
/* ── Blocking ─────────────────────────────────────────────── */
|
||||
|
||||
Reference in New Issue
Block a user