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

fix: more aggressive rate limit #1051

Merged
merged 1 commit into from
Jun 20, 2024
Merged

fix: more aggressive rate limit #1051

merged 1 commit into from
Jun 20, 2024

Conversation

styfle
Copy link
Owner

@styfle styfle commented Jun 20, 2024

Way too many requests coming from unknown clients. This will make sure clients identify themselves with a user-agent.

Copy link

vercel bot commented Jun 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
packagephobia ✅ Ready (Inspect) Visit Preview Jun 20, 2024 11:06pm

@styfle styfle merged commit fc3b43e into main Jun 20, 2024
5 checks passed
@styfle styfle deleted the rate-limit branch June 20, 2024 23:06
@mrazauskas
Copy link

mrazauskas commented Jul 9, 2024

In few repos I have packagephobia badges added via badgens badge service: https://badgen.net/packagephobia

Recently most of them started appearing as 429. Just wondering, if this change can be the reason? Should they change something on their side?

EDIT. Very likely this is the cause. If I get this right, here is how they are sending requests: https://github.com/badgen/badgen.net/blob/b58e0de1762eb0de37ab6318fb06eee32bc55796/pages/api/packagephobia.ts#L19-L20

@amio
Copy link
Collaborator

amio commented Jul 10, 2024

What about making the API response a bit longer in cache?

Currently, this response (https://packagephobia.com/v2/api.json?p=eloc) has a cache-control header: public, max-age=30. I think we can make it public, s-maxage=60, max-age=30 to have the Vercel CDN cache it for an additional 60s.

@styfle
Copy link
Owner Author

styfle commented Jul 10, 2024

Sounds good. But we also need badgen to set a user agent.

@amio
Copy link
Collaborator

amio commented Jul 11, 2024

429 issue fixed in badgen/badgen.net#673
preview https://badgennet-git-user-agent-badgen.vercel.app/#packagephobia/install/webpack

@mrazauskas
Copy link

Thanks! I just checked, all my badges are now fixed.

styfle added a commit that referenced this pull request Jul 11, 2024
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.

3 participants