Proposal: Prefetching in Phoenix LiveView

I read through this and I think it’s an interesting proposal. It seems like you’ve thought about this a lot :slight_smile:

The main differentiator between LiveView and other server-rendered frameworks is that it’s stateful, and can therefore be used for building pretty complex interfaces. As a result, it’s important to consider the consistency guarantees of a UI with pre-fetching built in.

For example, imagine we had a “forum” UI, with tabs representing categories and a “new post” button and accompanying modal. Now imagine a user hovered over a tab (triggering a prefetch), did not click it, and then opened the modal and made a new post in that category.

Then, after selecting the category, the old prefetch assigns would clobber the updated state (the state which includes the new post), and the user would be confused: “I just opened this, why is it out of date?”.

Of course, this does not preclude the inclusion of this feature (a perfectly valid counter would be “don’t use pre-fetching for that”), but I think it’s important to keep in mind that LV apps are usually more interactive and therefore have different expectations with regards to consistency than simple “static” websites. This feature would have to be used carefully.

2 Likes