Skip to content

Origin template caching, then transformed-HTML caching #852

Description

@aram356

Description

From the 2026-07-05 performance & architecture review (HTML cacheability section).

There is no CacheOverride, set_ttl, or cache API call anywhere in the repo. Origin fetches forward client cookies, and typical origins mark HTML private, so the readthrough cache passes. Every pageview is a full origin round trip plus a full rewrite cycle regardless of SSAT. The design doc's two-layer model (cached origin template + per-request assembly) is the correct target; it just needs to be built.

Fix

  1. Cache the origin HTML template explicitly (core cache or readthrough override) keyed by URL + host + variant, with cookies stripped from the template fetch, TTL + stale-while-revalidate. Origin load drops to roughly requests-per-URL-per-TTL.
  2. Go further and cache the transformed, auction-independent HTML. The rewrite output minus the two injected scripts is per-URL, not per-user. Late-bind only the bid splice per request. This eliminates the dominant per-request CPU too.
  3. Add Surrogate-Key emission and purge hooks so CMS purges propagate; today a stale cached origin object is uncontrollable except by TTL.
  4. Keep response_privacy.rs and the private, max-age=0 downgrade exactly as they are; the caching work sits upstream of them.

Effort / expected effect

  • Effort: Medium/Large
  • Expected effect: Origin RTT off the hot path; kills dominant per-request CPU.

Sequencing item 6 of 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions