Skip to content
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

Image Optimization: Add Rate Limiting and Bans #75

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

arunshenoy99
Copy link
Member

@arunshenoy99 arunshenoy99 commented Jan 21, 2025

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.

image

output.mp4

This has to go with: https://github.com/newfold-labs/cf-worker-image-optimization/pull/2

Type of Change

Production

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update
  • Refactoring / housekeeping (changes to files not directly related to functionality)

Development

  • Tests
  • Dependency update
  • Environment update / refactoring
  • Documentation Update

Video

Checklist

  • I have read the CONTRIBUTING doc
  • I have viewed my change in a web-browser
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants