Cache large drop-downs in Rails

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 #rails #rubyonrails #bosnia #programming #tutorials #rubydeveloper #railsdeveloper

Nezir Zahirovic

Freelance software developer Ruby On Rails (4 years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles