index category = Category.all render status: 200, json: category, each_serializer: CategorySerializer end end # Cache を利⽤した場合 def index render status: 200, json: cached_categories end def cached_categories Rails.cache.fetch("categories", expires_in: 24.hours) do category = Category.all render_to_string json: category, each_serializer: CategorySerializer end end