Step 10: Edge caching
Flx pages are built as an anonymous visitor, without cookies or query string, so a page is the same for everyone and a CDN can share it. Caching is a separate, opt-in step, taken after measuring (step 1's speed side).
Measure first
Run Lighthouse (PageSpeed Insights' engine) and time-to-first-byte on the live site and on a CI copy, native and Flx, before and after. The workflow used for Twenty Twenty-Five is .github/workflows/measure.yml. Its baseline: live TTFB about 200 ms, of which 120–190 ms at the origin (WordPress builds the page data and calls the renderer); Flx pages 120 KB against native 190–220 KB.
Turn it on
Follow Flx Modernize: edge caching:
- a Cache Rule on the CDN that caches only what the origin marks public, and skips login, password and comment cookies, query strings and
/wp-paths; - a purge-only API token and the zone ID in
wp-config.php; FLX_MODERNIZE_EDGE_TTL(Twenty Twenty-Five: 300 seconds).
Add the CDN rule first: on its own it changes nothing, because the site still sends private, no-store (Cloudflare shows BYPASS).
Prove it
In CI (tests/eligibility/check-edge-cache.sh), with the TTL on:
- pages, posts, the blog home page and category and tag archives are public;
- the same post with a query string, search, the 404, a private post, and a page where another plugin sets a cookie are not;
- logged-in visits, password posts, the native fallback and the renderer-down case are never public;
- each kind of change (publish, update, unpublish, trash, a new term, a changed tagline) purges once; drafts and unrelated options don't; nothing purges without credentials; the token is never logged.
One CI trap: PHP's opcache may keep an old wp-config.php when it is changed within the same second it was read. Wait and touch the file after each change.
On the live site, through the CDN: the first visit is MISS, the second HIT; search and ?x=1 stay uncached; after you edit a post, the next visit is MISS and shows the change.
Rollback: remove FLX_MODERNIZE_EDGE_TTL; pages are private, no-store again at once.
Published from rickey29/twenty-twenty-five at commit 837705d · Flx Modernize 1.11.0 · Flx Render 1.11.0