Serve /events/past from a page-level fragment on cache hits - #2979
Merged
Merged
Conversation
A warm hit now skips the COUNT, the eager loads, the decoration and the render, serving the whole page from one fragment keyed on locale, clamped page and MAX(updated_at) across the tracked tables. A 30-minute expiry bounds staleness that MAX(updated_at) alone cannot see (record deletions). Keys are minted only for pages that exist, so bogus page numbers cannot flood the cache store.
mroderick
force-pushed
the
perf/past-events-page-fragment
branch
from
October 1, 2026 11:39
1c71f4d to
23f7a37
Compare
mroderick
marked this pull request as ready for review
October 1, 2026 12:00
KimberleyCook
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.
Warm hits of
/events/pastnow serve the whole page from one cached fragment. On a hit the controller skips the COUNT, the eager loads, the decoration and the render; only theMAX(updated_at)etag query runs. The benchmarked prototype in #2976 measured an 84% cut in per-request allocations for the warm path (43,426 -> 7,104 GC objects) and 6 queries down to 1.The key is
[:events_past_page, I18n.locale, page, MAX(updated_at).to_f]acrossworkshops,meetings,eventsandmembers. Any tracked row change rotates every key, so edits appear on the next request. The page number is clamped the same way the fetch pipeline clamps it, so?page=0and?page=1share one fragment.Ref #2976
Review notes
Focus areas, in order:
read_fragmentand the view'scachewrite (skip_digest: true), and the.to_fencoding ofMAX(updated_at)— a rawTimestringifies differently between write and read (same convention assitemaps/show.xml.builder).MAX(updated_at), so a deleted event stays visible for up to 30 minutes (expires_in). The unchanged ETag path keeps its pre-existing exposure: a client holding a warmIf-None-Matchgets a 304 until any tracked row changes.skip_digestalso means deploys serve old markup for up to 30 minutes.requested_page <= @pagy.pages). Without the gate, bogus page numbers mint unlimited fragment keys, and Solid Cache evicts its oldest entries globally once overmax_size.Deliberately not done: the fragment covers
/events/pastonly;/events/upcomingkeeps its current path.Post-Deploy Monitoring & Validation
Intended behaviour: steady-state
/events/pastrequests drop to a single query (theMAX(updated_at)etag), visible in Scout APM query counts for the endpoint; pages keep rendering cards and pagination correctly across deploys. Regression signals: user reports of content stale beyond the 30-minute horizon while tracked tables are changing, or Solid Cache errors on the endpoint. Validation window: first 24-48 hours after deploy; owner: codebar maintainers.