-
Notifications
You must be signed in to change notification settings - Fork 70
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
Reduce ForumPost
requests on category pages
#4523
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hello @thesan I have tried to use local storage as persist cache for Apollo client. and then updated the code to use fetchPolicy as 'cache-only' for posts on Forum page. But i hope to know when and where will be the best to fetch 500 posts from the server and hope to get your opinion. |
892a928
to
87ea075
Compare
@thesan I have tried to reduce Graph queries by using memory cache by updating some calls. Also I integrated to fetch 500 latest posts per one day, but it looks like not good effect for this. Please review and give me feedback. |
fixes #4484 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mkbeefcake, sorry I wasn't checking my GH notifications lately so I completely missed your 3 messages.
Again the idea of relying on Apollo fetch policies is great but sadly I haven't had a very good experience with the Apollo cache either.
I detailed a solution closer to what I had in mind in the comments. It's not as good in theory because it assumes that enough of the currently showing threads and sub-categories have a post which is one of the 500 last updated ones else it shows a "-".
Finally I just thought of this but it would probably be safer to fetch the 500 last created post rather than updated.
@@ -11,6 +11,7 @@ export const useForumCategoryThreadCount = (category_eq: string, isArchive?: boo | |||
} | |||
const { data } = useGetForumThreadsCountQuery({ | |||
variables: { where: { category: { id_eq: category_eq }, status_json } }, | |||
fetchPolicy: 'cache-first', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mkbeefcake, thanks to you I finally got to test this idea. Here's the result on the "Joystream General" category:
- It works fine for the sub categories 4 out 4 here.
- It doesn't works well on the threads 5 out of 30.
This result is consistent on most categories. Sometime a few sub categories are missing their latest post but overall most sub categories have a latest post. However most thread latest posts are missing - except for the very active categories like "Pre-Proposals" which has a 30 out of 30 on the first page !
The solution could probably be tweaked a bit e.g:
- Increasing the amount cached posts from 500 to something a bit bigger.
- Decreasing the amount cached posts but filtering by category instead (for the threads last activity).
- Relying on the Apollo cache instead (like the way you started this PR) so that the missing still posts still get queried.
- Or a combination of these ☝️
However when I proposed this caching solution the query node were in a really bad shape which resulted in Pioneer being unusable for most people, so I felt that we needed to act fast even if it meant sacrificing some of the functionalities in the short term. Back then maybe this solution would have been acceptable but IMO now it's not. As a result, I don't think we should be spending time trying to tweak this short term solution now that the problem is not urgent anymore.
Instead I think we should focus on the long term solution which is Joystream/joystream#2599
What do you think @mkbeefcake ?
@chrlschwb even if this solution was viable this PR would need a bit more work, also #3868 would need to be finalized first (but I think this part should be done anyway). But even once its implementation is complete it turns out that the original idea I proposed isn't very good (see the screenshot of the "Joystream General" category ☝️). And since the QN are now working I don't think it's worth spending a lot of effort improving it because I think it will never be great, it will always be a short term trade-off until the QN issue can be addressed. However this change could be merged and maybe it could be applied to cc @mkbeefcake |
Tested on https://pioneer-2.vercel.app/#/forum/category/2 The number of requests when the page first loaded remained the same, but with continued interaction with the forum, the number of requests decreased significantly. Data display is OK 👍
|
Reduce `ForumPost` requests on category pages (Joystream#4523)
Fix 4484 : only using FetchPolicy at this moment
integrated persist cache with local storage.
need to discuss more with @thesan about the point when can fetch 500 posts from server.