Edge-compute patterns ⚡ (elective)
Purpose: Push personalisation, experimentation and composition to the CDN edge while AEM stays fully cacheable.
Who this page is for
| Audience | Why it matters to you |
|---|---|
| Architects / senior engineers | When cacheability and dynamism collide at scale |
⚡ Elective — pull in when client-side patterns stop being enough
The core rule stands: cached HTML is identical for everyone; dynamic bits load client-side (integration placement). Edge compute (CDN workers/functions) is the next step when client-side costs too much: flicker-free personalisation, geo/segment routing, experiment bucketing at scale.
Patterns worth their complexity
| Pattern | How | PHI example |
|---|---|---|
| Edge-side variant routing | Worker inspects cookie/geo → fetches one of N cached variants (.seg-families.html selectors — each fully cached) | Families vs singles hero on the plans landing page, no flicker |
| Edge HTML rewriting | Worker streams cached page, substitutes a marked slot from a fast edge KV lookup | "From $X/month" price freshness without page invalidation |
| Experiment bucketing | Worker assigns/persists bucket, routes to variant URLs | A/B at full cache speed, no client-side experiment flash |
| API composition at edge | Worker aggregates AEM JSON + pricing API for app clients | One round-trip for the mobile plan screen |
| Auth token verification | Worker validates JWT before origin | Members-area at edge speed |
The costs (why this is an elective)
- A second runtime with its own deploys, logs, limits and vendor lock surface — the pipeline, observability and versioning discipline all duplicate.
- Debugging spans three tiers (edge/dispatcher/publish); "which layer did this?" needs headers and log correlation designed in from day one.
- Variant explosion: N segments × M experiments multiplies cache entries — cache hit ratio math (capacity ⚡) must include it.
Adoption rule
Start with one pattern, one page family, full observability, and a documented fallback to the un-edged behaviour (worker off = plain cached page still correct). If a feature cannot degrade to that, it doesn't belong at the edge yet.