Cache large drop-downs in Rails
31-Jul-2019 1770
Today I noticed that a couple of drop-downs in a key form were taking several seconds to load.At first I figured it's a slow query, because the drop-downs load data from the DB and there's several dozen records. But, no, queries take only a couple of ms. It's the rendering that is slow.Implementing a view cache for the drop-downs is straightforward, just have to come up with an expirable key.The two core elements that can expire the cache are dropdown elements changing, and the selected value changing.Usually with view caches it is also prudent to scope the key to the resource id or other unique piece of data.
Cache large drop-downs in Rails #ruby #rubydeveloper #rubyonrails #Cache #large #drop-downs #Rails https://rubyonrails.ba/link/cache-large-drop-downs-in-rails