Files
news-platform/docs/PERFORMANCE_BASELINE.md
T
Artur MoreiraandCursor 9b6029f369 docs: fix Cloudflare cache verification (GET vs HEAD) after BIT-21847
Document GET-based curl checks, Free-plan contains paths, and Edge TTL
note aligned with cf-cache-rules-apply.sh. Add baseline operator footnote
and independent HIT smoke.

Co-authored-by: Cursor <[email protected]>
2026-05-12 22:42:29 +00:00

7.5 KiB
Raw Blame History

Performance Baseline — 2026-04-11

Audit Date: 2026-04-11T02:48:13+00:00 Auditor: Patrícia Santos (Agent) Reference: BIT-2080, docs/architecture.md § 6


Re-Measurement Addendum — 2026-05-12

Date: 2026-05-12T07:25:00+00:00 Auditor: Rosa Neves (COO Agent) Reference: BIT-21610

Cache-Control Headers — ✅ RESOLVED

BIT-2261 (Cache-Control on page responses) is done. Headers are now emitted on all Astro page routes:

cache-control: s-maxage=60, stale-while-revalidate=300

Confirmed on both domains (2026-05-12):

  • andebol.net — cache-control: s-maxage=60, stale-while-revalidate=300 ✓
  • newsproject.bitreport.pt — cache-control: s-maxage=60, stale-while-revalidate=300 ✓

TTFB Re-Measurement

Measurements repeated 2026-05-12T10:50 UTC (3 samples each):

Domain Min TTFB Median TTFB Max TTFB cf-cache-status
andebol.net 0.181s 0.233s 0.396s DYNAMIC
newsproject.bitreport.pt 0.229s 0.272s 0.295s DYNAMIC

Improvement: TTFB reduced from ~300ms (April baseline) to ~220ms typical (15–27% improvement from origin-side optimisations). Cache-Control headers confirmed present on every request.

Cloudflare HTML Cache Rule — ✅ APPLIED (2026-05-12)

Date: 2026-05-12T22:39 UTC Reference: BIT-21912 / BIT-21847

Cache Rule applied to both zones via deploy/scripts/cf-cache-rules-apply.sh (edge_ttl: override_origin, default: 60 s). Double-GET / verification:

Domain Pass cf-cache-status TTFB
andebol.net 1 HIT 0.090 s
andebol.net 2 HIT 0.081 s
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)
TTFB (cache MISS) < 200 ms ~220 ms ⚠️ Close; origin unchanged
Cache-Control headers present present ✅
cf-cache-status HIT HIT ✅

Operator trap: curl -I / HEAD can remain DYNAMIC while GET / is HIT — the live rule matches GET only (see deploy/scripts/cf-cache-rules-apply.sh). Always verify with GET (curl … -D - -o /dev/null).

Independent GET check (2026-05-12 ~23:02 UTC, CI runner): andebol.net pass1 EXPIRED / TTFB ~0.42 s, pass2 HIT / ~0.11 s; newsproject.bitreport.pt pass1–2 HIT / ~0.10–0.13 s — consistent with BIT-21912 closure evidence.

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).

Status: ⚠️ TARGETS NOT MET — Cache layer misconfiguration blocks target achievement.


Architecture Targets vs. Actual Measurements

Metric Target Actual Status Notes
TTFB (cache HIT) < 30 ms ~300 ms ❌ MISS No Cache-Control headers; Cloudflare marking as DYNAMIC
TTFB (cache MISS) < 200 ms ~300 ms ❌ MISS Same as HIT; cache not functioning
LCP < 2.5 s Not measured ⚠️ BLOCKED Requires Chrome DevTools or web.dev API
CLS < 0.1 Not measured ⚠️ BLOCKED Requires Chrome DevTools or web.dev API
Lighthouse Performance ≥ 90 Not measured ⚠️ BLOCKED npm environment issue; requires npm fix

Detailed Measurements

TTFB Analysis

andebol.net (Homepage)

URL: https://andebol.net
Response Size: 82 KB

Request 1 (warm cache):
  Time to First Byte: 0.309 s
  Total Time: 0.292 s

Request 2 (expected cache HIT):
  Time to First Byte: 0.302 s
  Total Time: 0.323 s

Response Headers:
  Cache-Control: [MISSING]
  cf-cache-status: DYNAMIC
  vary: accept-encoding
  Server: cloudflare

newsproject.bitreport.pt (Homepage)

URL: https://newsproject.bitreport.pt
Response Size: 33 KB

Request 1 (warm cache):
  Time to First Byte: 0.314 s
  Total Time: 0.308 s

Request 2 (expected cache HIT):
  Time to First Byte: 0.303 s
  Total Time: 0.342 s

Response Headers:
  Cache-Control: [MISSING]
  cf-cache-status: DYNAMIC
  vary: accept-encoding
  Server: cloudflare

Key Finding: Cache-Control Headers

Expected (per architecture):

Cache-Control: s-maxage=60, stale-while-revalidate=300

Actual:

Cache-Control: [NOT PRESENT]

This prevents:

  • ✗ Cloudflare from caching responses (status: DYNAMIC instead of HIT)
  • ✗ Browser from reusing cached pages
  • ✗ Achieving <30 ms TTFB target
  • ✗ Achieving <200 ms cache MISS target

Root Cause Analysis

The frontend (Astro) is not setting Cache-Control headers on responses. Per docs/architecture.md § 7 (Caching Strategy):

"HTTP Cache-Control: s-maxage + stale-while-revalidate — Set per route — Instructs CDN"

Missing Implementation:

  • No Astro.response.headers.set() calls in page components
  • No middleware setting cache headers
  • No Astro adapter configuration enabling response header management

Blocking Issues

Issue 1: Missing Cache-Control Headers (CRITICAL)

Impact: Prevents all TTFB target achievement Scope: Frontend (Astro pages) Action Required: Implement Cache-Control: s-maxage=60, stale-while-revalidate=300 on all page routes Files to Review: frontend/src/pages/*.astro


Measurement Limitations

The following metrics could not be measured due to environmental constraints:

  1. LCP / CLS (Core Web Vitals)

    • Requires Chrome DevTools Protocol or lighthouse CLI
    • npm environment has tsx dependency issue preventing lighthouse installation
    • Alternative: Use web.dev PageSpeed Insights API (requires key)
  2. Lighthouse Performance Score

    • Same npm issue prevents CLI invocation
    • Could be obtained via web.dev PageSpeed Insights or Chrome User Experience Report

Recommendation

Once Cache-Control headers are implemented:

  1. Run Lighthouse audit again (should see improvement from reduced TTFB)
  2. Measure LCP/CLS with web.dev or Chrome DevTools
  3. Update baseline with full metrics

Next Steps

  1. Immediate: Create BIT-2081 — Implement Cache-Control headers in Astro frontend
  2. After fix merged: Re-run full audit to validate target achievement
  3. Archive: Update this baseline document with complete measurements

Test Environment

  • LXC Container: news-project-test (CT 222), Ubuntu 24.04
  • Nginx: TLS termination, reverse proxy to Astro :4321
  • Cloudflare: Global CDN, account-level cache rules
  • Astro: SSR mode, Node.js adapter (standalone)
  • Test Client: curl (TTFB), standard HTTP/2

Appendix: Raw Measurement Data

Timestamp: 2026-04-11T02:48:13+00:00

andebol.net:
  Response: HTTP/2 200 OK, 82737 bytes
  Headers: [none cache-related]
  TTFB measurements: 0.309s, 0.302s (consistency across requests confirms no caching)

newsproject.bitreport.pt:
  Response: HTTP/2 200 OK, 33643 bytes
  Headers: [none cache-related]
  TTFB measurements: 0.314s, 0.303s (consistency across requests confirms no caching)