Users need to choose a car.
We have several drop-down lists when choosing a car, to select the year, make, model and submodel. Initially, we do not know what to use make / model / subodel to select options, since they are interdependent.
Once we select a year, we use ajax for queries that request ActiveRecord to populate the drop-down list.
Then, when we select make, we use ajax to query and populate the model drop-down list. Then, when we select the model, we ajax request and fill out the drop-down list of submodels.
The problem is that it is a lot of separate network requests, but in real conditions of low bandwidth, network problems, etc. quite often pauses occur that strongly affect the user interface and sometimes lead to crashes.
What approaches will help to avoid all these network requests. Would it be possible to save all several thousand combinations of model models in a client browser?
Currently, data is stored in an SQL database accessible through ActiveRecord in the Rails environment. Each drop-down list leads to a different query, because you cannot show the filling and showing make until you know the year, and you cannot fill and show the model until you know what to do. The same goes for submodels (although I skipped the submodel from the rest of this post for simplicity!).
Will the session ( http://simonsmith.io/speeding-things-up-with-sessionstorage/ ) store JSON data for 10,000 combinations? I see that sessionStorage can usually be relied upon to have at least 5 MB (5,200,000 bytes), so that gives me 5,200,000 / 10,000 = 520 bytes per record. Probably enough? If this is saved for the session and between pages, then in many cases we could actually drop it on the previous page, and if he had time to complete, we would not need an external call at all on the corresponding (next) page. We will need to update this data either from time to time or on demand, since new year-models of models are added periodically (several times a year).
Ultimately, I think that the solution here can be very useful for a large number of applications and companies. An example here is the choice of the car itself, which it uses by dozens of major car insurance sites (which now make multiple calls). A general assessment of client-side storage for relatioship dependent sdropdown can also be displayed in many other situations, such as making-brand-year online purchases. The backend framework for populating sessionStorage can also be implemented using various backend frameworks.
Other options might be google Lovefield attempts - https://github.com/google/lovefield Read more at https://www.youtube.com/watch?v=S1AUIq8GA1k It works with open source and works in ff, chrome, IE , Safari, etc.
It seems that sessionStorage might be better for our (significant) business than basing it on the google 100-day version of dev, although it's open source.