kiriDevs / vplanweb

A web app for the substitution plan of my school - data is supplied by an API maintained by @ChuangSheep
https://vplan.kiridevs.live
3 stars 0 forks source link

[WIP] Pre-Load substitution plans for different dates #40

Closed kiriDevs closed 2 years ago

kiriDevs commented 2 years ago

Pre-requisites

This proposal depends on #39 being implemented.

The Proposal

When the app loads, it could pre-load the substitution plans for all date options offered to the user. This would significantly improve the user experience as time-to-content after a date switch would drop to 0.

Potentially, this behaviour could be only applied conditionally to not apply if the user has indicated that they prefer applications to use less data (navigator.connection.saveData is true).

Considerations

ChuangSheep commented 2 years ago

As long as u do cache and don't rerequest this any time u reload the page, I don't see a problem. Not that many people use it anyway

kiriDevs commented 2 years ago

As long as u do cache and don't rerequest this any time u reload the page

These requests will probably be cached at some point, but probably not in the first version.

However, for this type of data a "cache-then-network" approach would likely make the most sense. On load, display cached data (if available) and make a request to the network. When the network request completes, update caches and display the new data.

I guess I could see if I could find a way to implement a sort of cooldown, so it doesn't try to load new data from the network automatically if the cached data is less than X minutes old (probably with 5 <= x <= 10). This could slightly decrease performance for the time between cache response and network response, since the cached response has to arrive and be checked before the network request is even started, but that might be a reasonable trade-off.