opentripplanner / otp-react-redux

A library for writing modern OpenTripPlanner-compatible multimodal journey planning applications using React and Redux.
MIT License
74 stars 53 forks source link

Premature optimization idea: cache route viewer data #64

Open evansiroky opened 5 years ago

evansiroky commented 5 years ago

In the current design of the route viewer as of 26b9a8a0d431fc7bd2f6b7097a8657dde82a43b6, the route polyline data is fetched anew each time a user clicks on a new route. In order to cut back on the number of API fetches for users that click back and forth between routes, we could store the response for certain routes in a in-browser cache and return that data to reduce the need for API requests.

evansiroky commented 5 years ago

In addition to caching this data we could also refactor the fetching of pattern geometry data so that only one action is sent after receiving all responses as opposed to having one action per response as exists here.

https://github.com/opentripplanner/otp-react-redux/blob/0e48ad4a82829ffe46e3b9e58fead605f0800466/lib/actions/api.js#L597-L602