I have a problem with a page that’s taking a long time to refresh a drop-down list. Basically on changing one drop-down value in a form, the potential options for a second drop-down change to a different list.
How can I speed this up? I’m using REDIS already for other reasons if that can help.
Thanks!
If you have few options in your primary select, then you could set all the possible secondary options in a js hash of arrays when you first render the page, then on change of the primary, lookup from this client-side js array – this is obviously fast, but could slow initial page load or bloat the page size if there are too many options.
Another way would be still make an ajax call when the primary select is changed, but cache the action that returns the secondary options. This would allow it to cache based on params form the request, and use the rendered result in the rails cache when possible (instead of always hitting redis or the db).