Cache the wall of fame body with a daily key - #2978
Merged
Merged
Conversation
Cache the rendered wall of fame template in Solid Cache, keyed on the UTC date, selected year, page number, and locale, with a 24-hour expires_in. Warm requests skip the distinct coach count, the grouped top-coach query, and the coach card render, which accounted for ~6% of all controller allocation churn on the site (issue #2974). The layout renders fresh on every request so fingerprinted asset URLs and meta tags are never stale; bump the v1 key segment when the view or its partials change.
…ached links Apply ce-code-review findings on the wall of fame cache: - Coerce page to an integer with pagy's own coercion so arbitrary strings cannot expand the cache key space. - Keep only the year (and pagy's page key) in pagy links so the filling request's junk query params are never frozen into the cached body.
…otation Past years' coach attendance is fixed, so only the current year needs a daily cache rotation. Past-year keys drop the date segment and carry no explicit expiry: entries age out via Solid Cache's max_age (2 weeks by default), so profile edits on old coach cards still propagate, just slower. Junk years stay on the dated, expiring path so they cannot create immortal entries.
mroderick
marked this pull request as ready for review
October 1, 2026 11:32
KimberleyCook
approved these changes
Oct 1, 2026
olleolleolle
reviewed
Oct 1, 2026
olleolleolle
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caches the rendered wall of fame body (
DashboardController#wall_of_fame, /coaches) in Solid Cache under a daily key. Closes #2974.What changes
Measured impact
Benchmarks against master on the local production dump (production mode, Solid Cache, real data: 3,575 attended coaches), median of 5 warm requests:
/coaches/coaches?page=2/coaches?year=2024A cache miss costs the same as an uncached render plus two cache writes, and only the first request per key per day pays it. Applied to the drain figures in #2974 (42.7M GC allocations/week), the warm-hit reduction projects to roughly 28M allocations/week saved.
Staleness
The list changes only when a coach attends a workshop, so a 24-hour window is acceptable for this page. The controller comment documents that the key version (
v2) must be bumped when the view or its partials change.Only the current year's data changes with new attendance, so past-year keys drop the date segment and carry no explicit expiry: entries age out via Solid Cache's
max_age(2 weeks by default) instead of rotating at midnight. On the production dump that leaves ~39 dated keys rotating daily and ~861 past-year keys (year × page × 3 locales) always warm. Profile edits on old coach cards propagate within that 2-week window rather than within 24 hours. Junk years keep the dated, expiring key so arbitrary requests cannot create immortal entries.Reviewer notes
Focus on the cache key design and the staleness tradeoff:
coaches/wall_of_fame/v2/#{date}/#{year}/#{page}/#{locale}withexpires_in: 24.hours; past years (2013..current−1) drop the date segment and expiry. The date segment means a New Year rollover rotates the current year's keys automatically.max_age). If that proves too coarse, shorten the expiry — no key-format change needed.Detail
render_to_stringincluding the layout; this PR deliberately renders the layout fresh instead. Caching fingerprinted asset URLs for 24 hours would serve stale asset links after a deploy, the reason Cache the rendered /sponsors page body — recurring 1.3s render stalls dyno threads #2885 cached only the partial.pageto the integer pagy will render, and strips everything butyearand pagy's ownpagekey from link URLs. A pre-existing, unrelated bug inpage_year?(application_helper.rb:82, Integer-vs-String comparison, so the active year button never highlights) is out of scope here; fixing it will require a key-version bump since the button state is inside the cached body.