Image Optimization: Add Rate Limiting and Bans #75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR introduces support for rate limiting and banning sites that abuse the Image Optimization API. When a site exceeds its allowed request limit within a specified time window, the CF Worker returns a 429 Too Many Requests status code, and the site is temporarily rate limited. Admins are notified via a banner in the WordPress admin area, showing the retry time before further requests can be made. If a site exceeds the monthly hard limit (usually a large number), it is permanently banned, and the Worker returns a 403 Forbidden status code. In this case, a banner informs the admin that the site has been banned and provides a link to contact support.
output.mp4
This has to go with: https://github.com/newfold-labs/cf-worker-image-optimization/pull/2
Type of Change
Production
Development
Video
Checklist
Further comments