A Rails app's homepage makes 12 database queries on every load. After profiling, navigation categories are queried every request. Best fix?
-
A
Add a database index on categories.name
-
B
Cache the navigation fragment with Rails.cache or fragment caching
-
C
Preload categories in ApplicationController with a before_action
-
D
Store categories in a YAML config file