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

Separate the homepage categories API from the AOTD and Banners #4343

Open
GeopJr opened this issue Dec 22, 2024 · 6 comments
Open

Separate the homepage categories API from the AOTD and Banners #4343

GeopJr opened this issue Dec 22, 2024 · 6 comments

Comments

@GeopJr
Copy link

GeopJr commented Dec 22, 2024

Recently I had an issue where the 'updated' category API response was cached but the others weren't. That led to the AOTD being the previous day's and the other categories having that day's.

Would it possible to separate them into two endpoints? One for the categories and another for the banner / AOTD?

edit: Actually if all en.json?category=<category> return all other categories as well, why are they separate endpoints to begin with, instead of just en.json?

@razzeee
Copy link
Member

razzeee commented Dec 22, 2024

They are already separate? I'm not sure what you're calling - I guess you're not actually using the real backend? https://flathub.org/api/v2/docs

Keep in mind, that we don't keep the api stable and don't give gurantees

@GeopJr
Copy link
Author

GeopJr commented Dec 22, 2024

I'm talking about flathub.org. The problem I encountered was that

en.json?category=new was cached in my browser and had the previous day's AOTD, while the other tabs had the current day's.

So switching between Trending, Popular, New, Updated showed different AOTD.

What I'm suggesting is completely decoupling AOTD from en.json or not GETing a separate en.json for each category (since they all have the same data as far as I can tell). That way browsers won't have 4 different cached versions.

Not sure if I'm misinterpreting things, but the AOTD became the same among all categories only after I cleared my cache completely.

@razzeee
Copy link
Member

razzeee commented Dec 22, 2024

In general, we need stuff to be cached. What you're seeing is also an automatic mechanism, caches die after some amount of time on the server side and will then get regenerated with the next request hitting them for that language.

We don't configure at all what en.json does, that's all automatic.

@GeopJr
Copy link
Author

GeopJr commented Dec 22, 2024

I'm doing a terrible job at describing it and probably misunderstanding how it works, it's not that important or serious but let me try one more time:

This is an edited recording to showcase what I experienced. The 'New' category's en.json was cached in my browser with the previous day's AOTD while the other categories weren't. That caused flathub to show different AOTD based on the current category

Screencast.From.2024-12-22.22-10-07.mp4

What I'm suggesting is either:

  1. Separating the AOTD and banners from the categories. So e.g. /aotd.json gets cached separately from /en.json and its categories. That way the cache mishap like in the recording above wouldn't happen.
  2. Or as noted by my edit, probably get rid of the separate per category en.json

image

There are 5 different endpoints that get cached individually but return the same data. en.json, en.json?category=trending, en.json?category=popular, en.json?category=new, en.json?category=updated. My initial issue was caused by that I assume, en.json?category=new had an older cache than the other en.jsons and therefore an older AOTD.

Getting rid of the separate en.jsons would also help in bandwidth as browsers would only request and cache en.json instead of 5 different ones (that return the exact same data)

@GeopJr
Copy link
Author

GeopJr commented Dec 22, 2024

I think this is a similar issue vercel/next.js#27638

edit: from what I gathered, it's not possible to make it ignore query params on getStaticProps, so each ?cageory= is not treated as a different page?

@GeopJr
Copy link
Author

GeopJr commented Jan 8, 2025

Had this happen again today, the AOTD was OBS and it only updated to GNOME Extensions after clicking the 'New' tab

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

No branches or pull requests

2 participants