bonfire-networks / bonfire-app

Bonfire - tend to your digital life in community. Customise and host your own online space and control your experience at the most granular level.
https://bonfirenetworks.org
GNU Affero General Public License v3.0
522 stars 37 forks source link

Query the primary feed in the background to preload the activities so they can be shown instantly when the user navigates to the feed page #901

Open mayel opened 4 months ago

mayel commented 4 months ago

Still to-do (eg. broken as a result of this refactor)

Stretch goals


The goal is to fetch and cache the activities in a separate elixir process as soon as the user is logged in, to reduce the loading time when showing the feed.

Implementation details

After considering and prototyping several different approaches, it seems like we may have ended up with the most high level optimisation possible (compared to caching DB queries or any steps in between):

Now when signed in to Bonfire, no matter what page you're on you can click to view the feed and it appears instantly (it is already loaded in the background and rendered in a hidden div).

In this way every time you view the feed we avoid using extra resources and time for:

Of course it comes at the cost (especially when a user doesn't end up viewing their feed) of using extra:

And it requires that we fix and extensively test PubSub (see #839) to make new activities appear at top of the feed since user is not reloading it (and it would be even more of a resource waste to simply reload it every minute or whatever)