docs: revise Free-plan HIT TTFB contract to <150ms (BIT-28133)
Tests / bridge tests (push) Successful in 6m6s
Tests / writer-pipeline tests (push) Successful in 8m2s
Tests / writer-pipeline tests (pull_request) Successful in 4m43s
Tests / frontend lib tests (push) Successful in 4m57s
Tests / frontend lib tests (pull_request) Successful in 6m2s
Tests / bridge tests (pull_request) Successful in 6m17s

Align architecture, PERFORMANCE_BASELINE, PROJECT_STATUS, and deployment
docs with measured Cloudflare Free edge HIT (~81–130 ms). Keep GET vs HEAD
operator traps; document optional paid path without committing spend.

Paperclip-Issue: BIT-28133
Paperclip-Run: ec99ea35-a42c-4198-a9d8-66ce79bb13ad
This commit is contained in:
José Alves committed 2026-08-04 20:23:44 +01:00
1 parent 8057f1ffee
commit 792d1c090d
4 files changed
+47 -10

No files matched your search

+34 -5
View File
@@ -6,6 +6,33 @@
---
## Production contract decision — 2026-08-04 (BIT-28133)
**Decision: (A) revise the documented HIT TTFB target** to what Cloudflare **Free** + the current Cache Rules stack sustain. Do **not** treat the old aspirational **< 30 ms** figure as the production SLA while staying on Free.
| Metric | Previous aspirational | Production contract (Free) | May 2026 measured | Status |
|--------|----------------------|----------------------------|-------------------|--------|
| TTFB (cache HIT) | < 30 ms | **< 150 ms** (P95, operator `GET`) | ~81–130 ms | ✅ Met under revised contract |
| Edge `cf-cache-status` | HIT | HIT on repeat `GET /` | HIT | ✅ |
| TTFB (cache MISS, bridge cached) | < 200 ms | < 200 ms | ~220 ms typical | ⚠️ Close; origin-side work, not plan upgrade |
| Cache-Control on pages | present | `s-maxage=60, stale-while-revalidate=300` | present | ✅ |
**Rationale:** Edge HTML caching is confirmed (`HIT` on both production zones). Remaining HIT latency (~80–130 ms) is dominated by Free-plan edge delivery + probe RTT/TLS from typical EU/PT paths, not by a missing Cache Rule. Calling objective #2 “unmet” against < 30 ms while marking it delivered creates a silent contradiction with `PROJECT_STATUS` / architecture.
**Optional path (B) — not chosen as the production contract:** to chase sub-30 ms HIT (or further MISS improvement), board can evaluate paid Cloudflare options later:
| Option | Role | Order-of-magnitude cost (indicative) |
|--------|------|--------------------------------------|
| Confirm **Smart Tiered Cache** enabled | Improves MISS/fill more than steady-state HIT TTFB | Free on current plans when available |
| **Pro** per zone | Extra caching/WAF features; not a guaranteed < 30 ms HIT | ~$20–25 / zone / month |
| **Argo Smart Routing** | Last-mile routing; may cut TTFB on some paths | ~$5 / month base + ~$0.10 / GB (usage) |
Any spend requires formal board approval; this issue does **not** commit to B.
**Canonical targets:** [`docs/architecture.md`](architecture.md) § 6. Status parity: [`docs/PROJECT_STATUS.md`](PROJECT_STATUS.md) objective #2.
---
## Re-Measurement Addendum — 2026-05-12
**Date:** 2026-05-12T07:25:00+00:00
@@ -49,9 +76,9 @@ Cache Rule applied to both zones via `deploy/scripts/cf-cache-rules-apply.sh` (`
| newsproject.bitreport.pt | 1 | **HIT** | 0.129 s |
| newsproject.bitreport.pt | 2 | **HIT** | 0.101 s |
| Metric | Target | Actual | Status |
|--------|--------|--------|--------|
| TTFB (cache HIT) | < 30 ms | ~81–130 ms | ⚠️ Edge HIT confirmed; TTFB above < 30 ms target (Free plan, no Argo/Tiered Cache) |
| Metric | Target (at measurement) | Actual | Status (under BIT-28133 contract) |
|--------|-------------------------|--------|-------------------------------------|
| TTFB (cache HIT) | was < 30 ms (aspirational) | ~81–130 ms | ✅ Meets revised **< 150 ms** Free-plan contract; edge HIT confirmed |
| TTFB (cache MISS) | < 200 ms | ~220 ms | ⚠️ Close; origin unchanged |
| Cache-Control headers | present | present | ✅ |
| cf-cache-status | HIT | HIT | ✅ |
@@ -62,9 +89,11 @@ Cache Rule applied to both zones via `deploy/scripts/cf-cache-rules-apply.sh` (`
## Executive Summary
Baseline performance audit reveals **critical cache implementation gap**: Neither production domain is returning `Cache-Control` headers, preventing Cloudflare edge caching. TTFB measurements show ~300ms for all requests instead of target <30ms (cache HIT) / <200ms (cache MISS).
> **Superseded for current status.** April 2026 findings below are historical. Cache-Control + Cloudflare Cache Rules are applied (May 2026); production HIT TTFB contract was revised in [BIT-28133](/BIT/issues/BIT-28133) — see addendum at top of this file and [`docs/architecture.md`](architecture.md) § 6.
**Status:** ⚠️ **TARGETS NOT MET** — Cache layer misconfiguration blocks target achievement.
Baseline performance audit (2026-04-11) revealed a **critical cache implementation gap** at the time: neither production domain returned `Cache-Control` headers, so Cloudflare marked responses `DYNAMIC`. TTFB was ~300 ms for all requests versus the then-aspirational <30 ms (cache HIT) / <200 ms (cache MISS).
**Status (April snapshot):** ⚠️ **TARGETS NOT MET** — Cache layer misconfiguration blocked target achievement. **Status (current):** ✅ Edge HIT delivered; HIT TTFB contract **< 150 ms** on Free (measured ~81–130 ms).
---
+2 -2
View File
@@ -9,7 +9,7 @@ Alinhados à descrição do projecto no Paperclip e ao [`docs/architecture.md`](
| # | Objectivo | Notas |
|---|-----------|--------|
| 1 | **Plataforma multi-domínio** | Suporte a múltiplos domínios sem alteração de código — apenas ficheiros JSON de config por domínio. |
| 2 | **Frontend SSR performante** | Astro 5 SSR: TTFB < 200 ms (bridge cached), LCP < 2.5 s, CLS < 0.1, Lighthouse ≥ 90. |
| 2 | **Frontend SSR performante** | Astro 5 SSR: TTFB cache HIT **< 150 ms** (Cloudflare Free contract, [BIT-28133](/BIT/issues/BIT-28133)); MISS < 200 ms (bridge cached); LCP < 2.5 s, CLS < 0.1, Lighthouse ≥ 90. |
| 3 | **Bridge Fastify + cache Redis** | Camada de normalização e cache entre frontend e WordPress headless (TTL 60 s artigos). |
| 4 | **WordPress headless** | CMS headless via REST API; sem tema renderizado — apenas editorial no WP Admin. |
| 5 | **SEO de primeira classe** | SSR full-page, Schema.org `NewsArticle`, Open Graph, Twitter Card, sitemap dinâmico. |
@@ -26,7 +26,7 @@ Alinhados à descrição do projecto no Paperclip e ao [`docs/architecture.md`](
| # | Objectivo | Estado | Rastreio principal |
|---|-----------|--------|--------------------|
| 1 | Plataforma multi-domínio | ✅ Entregue | [BIT-345](/BIT/issues/BIT-345), [BIT-494](/BIT/issues/BIT-494)–[BIT-497](/BIT/issues/BIT-497) |
| 2 | Frontend SSR performante | ✅ Auditoria + validação prod + edge cache (HIT) | [BIT-349](/BIT/issues/BIT-349); [BIT-2080](/BIT/issues/BIT-2080) / [BIT-21610](/BIT/issues/BIT-21610) `done`; Cloudflare [BIT-21847](/BIT/issues/BIT-21847) / [BIT-21912](/BIT/issues/BIT-21912) — [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md) |
| 2 | Frontend SSR performante | ✅ Entregue sob contrato Free: edge HIT + HIT TTFB < 150 ms (~81–130 ms medido) | [BIT-349](/BIT/issues/BIT-349); [BIT-2080](/BIT/issues/BIT-2080) / [BIT-21610](/BIT/issues/BIT-21610); CF [BIT-21847](/BIT/issues/BIT-21847) / [BIT-21912](/BIT/issues/BIT-21912); contrato TTFB [BIT-28133](/BIT/issues/BIT-28133) — [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md) |
| 3 | Bridge Fastify + Redis | ✅ Entregue | [BIT-350](/BIT/issues/BIT-350), [BIT-2076](/BIT/issues/BIT-2076) (Redis extension fix) |
| 4 | WordPress headless | ✅ Entregue | [BIT-351](/BIT/issues/BIT-351) |
| 5 | SEO de primeira classe | ✅ Entregue | [BIT-349](/BIT/issues/BIT-349) — SSR, JSON-LD, OG, sitemap, robots |
+8 -2
View File
@@ -124,7 +124,7 @@ A scalable, multi-domain news platform designed for high traffic. Built on a hea
Browser
→ GET https://newsproject.bitreport.pt/futebol/porto-bate-benfica
→ Cloudflare CDN checks edge cache
HIT → return cached HTML (TTFB: ~10–30 ms)
HIT → return cached HTML (TTFB: typically ~80–130 ms on Free plan; contract < 150 ms)
MISS → forward to Nginx
→ Nginx → Astro SSR (:4321)
→ Astro reads host header
@@ -280,9 +280,11 @@ Article pages emit `NewsArticle` JSON-LD:
## 6. Performance Targets
Production contract (Cloudflare **Free** + Cache Rules as of [BIT-28133](/BIT/issues/BIT-28133); evidence in [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md)):
| Metric | Target | Strategy |
|--------|--------|----------|
| TTFB (cache HIT) | < 30 ms | Cloudflare edge cache |
| TTFB (cache HIT) | **< 150 ms** (P95) | Cloudflare edge cache (`cf-cache-status: HIT` on `GET`); typical ~80–130 ms from EU/PT probes |
| TTFB (cache MISS, cached bridge) | < 200 ms | Redis in bridge |
| TTFB (cold, WP fetch) | < 800 ms | Bridge normalizes quickly; WP is internal |
| LCP | < 2.5 s | SSR HTML, preload hero image, no hydration waterfall |
@@ -290,6 +292,10 @@ Article pages emit `NewsArticle` JSON-LD:
| FID / INP | < 200 ms | Near-zero JS, islands only for interactive elements |
| Lighthouse Performance Score | ≥ 90 | SSR + minimal JS + image optimization |
**Contract note (HIT TTFB):** The earlier aspirational **< 30 ms** HIT figure is **not** the Free-plan production SLA. May 2026 double-`GET` probes showed edge **HIT** at ~81–130 ms with Cache Rules applied — functional caching is delivered; sub-30 ms needs paid routing/collocated measurement (see optional upgrade path in `PERFORMANCE_BASELINE.md`). Do not mark objective #2 unmet solely because HIT TTFB is above 30 ms while `cf-cache-status: HIT` and the < 150 ms contract hold.
**Operator trap:** Cache Rules match **`GET`** only — `curl -I` / **HEAD** can show `DYNAMIC` while **`GET /`** is **HIT** (see `deploy/scripts/cf-cache-rules-apply.sh` and `docs/deployment.md`).
### Image Optimization
- Astro's `<Image />` component: automatic WebP conversion, `width`/`height` attributes prevent CLS
+3 -1
View File
@@ -119,7 +119,9 @@ The checked-in `deploy/nginx/newsproject.bitreport.pt.conf` proxies WordPress on
## Cloudflare — HTML edge cache (Cache Rules)
Public HTML is served through Cloudflare. **Default behaviour:** Cloudflare marks HTML as **not eligible** for the edge cache unless a **Cache Rule** says otherwise, so responses stay `cf-cache-status: DYNAMIC` even when the origin sends `Cache-Control: s-maxage=60, stale-while-revalidate=300` (see [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md) § *Remaining Gap — Cloudflare HTML Caching*).
Public HTML is served through Cloudflare. **Default behaviour:** Cloudflare marks HTML as **not eligible** for the edge cache unless a **Cache Rule** says otherwise, so responses stay `cf-cache-status: DYNAMIC` even when the origin sends `Cache-Control: s-maxage=60, stale-while-revalidate=300` (see [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md)).
**Production TTFB contract (BIT-28133):** with Cache Rules applied on Cloudflare **Free**, expect edge **HIT** TTFB typically **~80–130 ms** and treat **< 150 ms** (P95, `GET` probes) as the SLA — not the old aspirational < 30 ms. See [`docs/architecture.md`](architecture.md) § 6 and the BIT-28133 addendum in [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md).
This is **board / DevOps configuration** in the Cloudflare dashboard (or API/Terraform) for **each zone** that fronts a news-platform hostname — today **`andebol.net`** and **`newsproject.bitreport.pt`**. Repeat the same rule on both zones if they use separate zones.