Emergency drastic changes to Lemmy, maybe hacking on lemmy-ui is easiest #6
RocketDerp
started this conversation in
Ideas
Replies: 2 comments
-
For non-logged in users, caching of the front page content also can be done, here is the place in the code: |
Beta Was this translation helpful? Give feedback.
0 replies
-
Proof of concept, not very pretty JavaScript/TypeScript code:
also you need to do:
This could could be put into an independent file, use a common function with parameters. It also doesn't get called for users navigating within the page and not dong full page refreshes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The front-page of a lemmy site is typically running lemmy-ui, maybe emergency performance changes are easiest done in that codebase.
For example, the "Trending" in the upper right is live-fetched from SQL via the Rust API on every front-page refresh. Caching this in lemmy-ui would be a start, and this data is not unique to the user:
Code:
https://github.com/LemmyNet/lemmy-ui/blob/1700476528d20ecbe68c7700c1cd097eb700b99a/src/shared/components/home/home.tsx#L360C1-L360C1
I've worked with https://github.com/jaredwray/keyv keyv library and SQLite module within it for caching.
Store two things, first the JSON that the Rust API returns, second a last-update time. Then add Javascript date comparison and if over 1 hour old, immediately set the update value (to prevent concurrency), then do the live API fetch. I would also add the same to the site /communities JSON results, by page.
Beta Was this translation helpful? Give feedback.
All reactions