mojang-api icon indicating copy to clipboard operation
mojang-api copied to clipboard

Investigate longer cache times

Open JamsheedMistri opened this issue 2 years ago • 15 comments
trafficstars

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.

JamsheedMistri avatar Dec 31 '22 03:12 JamsheedMistri

Hi, taking a look at the issue

Electroid avatar Dec 31 '22 15:12 Electroid

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

Electroid avatar Jan 01 '23 18:01 Electroid

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

andreasdc avatar Jan 01 '23 19:01 andreasdc

@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 avatar Jan 03 '23 06:01 JamsheedMistri

@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).

JamsheedMistri avatar Jan 03 '23 23:01 JamsheedMistri

I think cache time is set to 60 hours

andreasdc avatar Jan 03 '23 23:01 andreasdc

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.

Electroid avatar Jan 03 '23 23:01 Electroid

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.

andreasdc avatar Jan 03 '23 23:01 andreasdc

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.

Electroid avatar Jan 03 '23 23:01 Electroid

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?

JamsheedMistri avatar Jan 03 '23 23:01 JamsheedMistri

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

andreasdc avatar Jan 03 '23 23:01 andreasdc

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

JamsheedMistri avatar Jan 30 '23 18:01 JamsheedMistri

@Electroid Any progress on the updated API?

CraftedFury avatar Mar 16 '23 06:03 CraftedFury

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

ismhdez avatar Mar 23 '23 01:03 ismhdez

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

samfces avatar Jun 13 '23 08:06 samfces