Electroid / mojang-api

Bundle multiple Minecraft APIs into a single GET request.
https://api.ashcon.app/mojang/v2/user/Notch
MIT License
242 stars 17 forks source link

Investigate longer cache times #66

Open JamsheedMistri opened 1 year ago

JamsheedMistri commented 1 year ago

The user d659e53b3f9e4488818fa2d0732789ae changed their username to jji 4 days ago (Dec 26), but the API is currently returning their old username, Dxw (link). Querying jji will result in a 404 (link).

I inspected your code and it seems like the cahce TTL is only 1 hour for this endpoint, so idk why it would be out of date by 4 days.

Electroid commented 1 year ago

Hi, taking a look at the issue

Electroid commented 1 year ago

The cache TTL has been fixed, names and profiles should be properly updating now.

andreasdc commented 1 year ago

What's the cache time right now? If it's 1 hour is still pretty long.

JamsheedMistri commented 1 year ago

@Electroid the longer cache time issue seems to still be persisting. User k5s registered an account more than 1 hour ago, but querying their username (link) gives a 404. Querying their UUID works though (link).

JamsheedMistri commented 1 year ago

@Electroid additionally, querying user 4bk yields a user whose name was previously 4bk but is no longer. It shows their new username on the response. The name change was around 17 hours ago. (link).

andreasdc commented 1 year ago

I think cache time is set to 60 hours

Electroid commented 1 year ago

Right now it's a random time between 1 and 24 hours. This is obviously not great, but otherwise there are too many 429 errors and nothing can get updated.

I've been working on a rewrite, since December, which is able to get around these limitations. It's about a week or two away from being rolled out. After that, the cache time will be about 5 minutes.

andreasdc commented 1 year ago

You have a backup server that you mentioned some time ago, 429 errors depend on cloudflare itself too, but caching 1 player for such a long time is not a good solution.

Electroid commented 1 year ago

There is so much volume, even the backups (there are multiple servers) are getting rate limited. As I said, this is a temporary solution until the new system is rolled out.

JamsheedMistri commented 1 year ago

Right now it's a random time between 1 and 24 hours. This is obviously not great, but otherwise there are too many 429 errors and nothing can get updated.

I've been working on a rewrite, since December, which is able to get around these limitations. It's about a week or two away from being rolled out. After that, the cache time will be about 5 minutes.

Looking forward to the rewrite! Out of curiosity, how's it being done? Are you just upping the amount of requester nodes and doing a round-robin style? Is there a branch we can see the progress on?

andreasdc commented 1 year ago

Maybe create a password type of key to limit some users which may make too many requests.

JamsheedMistri commented 1 year ago

@Electroid Any update on getting the new API rolled out?

CraftedFury commented 1 year ago

@Electroid Any progress on the updated API?

ismhdez commented 1 year ago

The TTL must be too high, an account created on Mar 18 is still appearing as 404 Not Found on 23 Mar 😵‍💫🤔

samfces commented 1 year ago

We are having the same problem. An account changed his name two weeks ago and account still appears as 404