Skip to content

perf: cache home page body for anonymous visitors per label and locale - #1232

Merged
salzig merged 2 commits into
masterfrom
feat/cache_anonymous_home
Nov 10, 2026
Merged

salzig merged 2 commits into
masterfrom
feat/cache_anonymous_home

Conversation

@salzig

@salzig salzig commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

The home page takes 47% of all app time (AppSignal, last 30 days: 786,000 requests at 78 ms mean) and is rebuilt from nine queries on every request, almost always for logged-out visitors.

  • Only the body is cached, the layout stays live: the navigation and <head> carry per-session CSRF tokens (the login buttons are POST forms), and the hint area shows flash messages. The body is identical for every logged-out visitor of a label.
  • Per label, not per host: the key uses the resolved label, so www.rug-b.de and berlin.onruby.eu share an entry and an unknown subdomain cannot create new ones.
  • Staleness: logged-out visitors see a new event, topic or attendee after up to five minutes. Signed-in users always get the live page.
  • Memory store: there is one web process, so nothing needs sharing. At most 48 entries (12 labels × 4 locales) of 20–30 kB, about 1.5 MB of the 32 MB limit.
  • ?time_zone= is removed first: it would otherwise have to be part of the cache key. Nothing on the site links to it; it has been a hand-typed URL parameter since 2015. The label's default zone is still applied.
  • Checked by hand: on a local production boot the Hamburg home page went from 19 ms to 11 ms (median of 30), Berlin from 14 ms to 6 ms, and the cached page is identical to the uncached one apart from whitespace and CSRF tokens.

@salzig
salzig merged commit 24e85a0 into master Nov 10, 2026
1 check passed
@salzig
salzig deleted the feat/cache_anonymous_home branch November 10, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants