Micro-caching dynamic HTML without serving stale logins
A classifieds site in Warsaw refused to cache HTML — "it's dynamic" — so every one of 2M daily pageviews hit PHP. Origin ran 12 app servers just to keep up.
We introduced HTML micro-caching, carefully:
— Cached anonymous HTML for just 5 seconds at the edge
— Added a hard bypass: if a session cookie is present, never serve or store the cached copy
— Kept POST, search, and account routes entirely uncached
— Used stale-while-revalidate so the 5s refresh happened in background
— Load-tested with logged-in accounts to prove no cross-user leakage
Even a 5-second cache collapsed duplicate requests massively — a listing viewed 400 times in 5 seconds hit origin once. They dropped from 12 app servers to 4. The non-negotiable step is the cookie bypass; skip it and you serve one user's session to the next.
The number that mattered: 8 app servers retired by a 5-second cache.
Edge of Glory
@EdgeOfGloryCDN
Micro-caching dynamic HTML without serving stale logins
Этот пост опубликован в Telegram-канале Edge of Glory. Подписаться можно по ссылке: @EdgeOfGloryCDN.