Mid-level Track Roadmap

API: fast serialization

This course examines how a Rails app's Jbuilder views serialize JSON and when caching that output is worth it. It traces the two branches of array!, the block form and the partial form with cached:, and shows the batched cache reads the partial form triggers. It covers json.cache! and its use of Rails.cache, and render json:, which skips ActionView and Jbuilder. It compares the app's HTML fragment caching and weighs every mechanism against the search view's limit of eight results per type.

What you'll learn

  • ✓The block and partial branches of Jbuilder's array!
  • ✓Batched cache reads through ActionView::CollectionRenderer with cached:
  • ✓How json.cache! reads and writes Rails.cache
  • ✓What render json: skips compared with a Jbuilder view
  • ✓Single-key and collection fragment caching in the app's HTML
  • ✓Judging caching against the search view's size
Free preview · Lesson 1 3 min read

This app's array views take the simple path

The junior course "API development: Jbuilder" read this app's .json.jbuilder views. Several of them build arrays: the catalogue search behind the command palette, and the partner API's lists of learners, certificates and activity. The search view is the simplest:

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...