Session 8 — Dispatcher, caching & delivery
Purpose: Understand how the Dispatcher caches, filters and invalidates — the difference between a fast AEM site and a melting one.
Who this page is for
| Audience | Why it matters to you |
|---|---|
| All engineers | Every component you build has a caching consequence |
What the Dispatcher is
An Apache/IIS module in front of publish doing three jobs: cache rendered pages as files on disk, filter which requests are allowed through, and load-balance across publish instances. Mentally: Nginx + CDN with a content-aware invalidation hook.
GET /plans/gold-hospital.html
Visitor ──▶ CDN ──▶ Dispatcher ──cache HIT──▶ serve file from docroot
│
cache MISS
▼
Publish renders ──▶ file written to docroot ──▶ served & cached
The two config files that matter
| File | Controls | Key sections |
|---|---|---|
| dispatcher.any | Caching & routing | /filter (allow/deny rules), /cache (/rules what to cache, /invalidate what flushes), /farms |
| httpd.conf / vhosts | Web server basics | vhosts, rewrites, headers |
What gets cached (and what silently doesn't)
| Request | Cached? | Why |
|---|---|---|
| GET /plans/gold-hospital.html | Yes | GET, has extension, no query string |
| GET /plans/gold-hospital.html?campaign=x | No (by default) | Query string bypasses cache — use /ignoreUrlParams for known tracking params |
| POST anything | No | Non-GET is never cached |
| GET with Authorization header | Not by default | Requires explicit /allowAuthorized decisions |
| URL without extension | Often not cacheable as a file | Always link with extensions in AEM |
Invalidation
On publish/activation, AEM sends a flush request; the dispatcher touches .stat files. Any cached file older than the nearest .stat above it is re-fetched on next request — that is statfileslevel. Auto-invalidation is why authors' changes appear without any deploy: publish the PHI plan page, its cached HTML is invalidated, next visitor triggers a fresh render.
Developer consequences
- Personalised/user-specific markup cannot live in cached page HTML — fetch it client-side or via AJAX endpoints excluded from cache.
- Components must render identically for all users, or the first user's version is what everyone gets.
- Cache-bust static resources by versioned clientlibs, never by query strings.
- Design URLs with extensions and stable paths; selectors are cache-friendly variants.