From 9b6029f369a8aa92533e2a3f24555bfe8fc7b8bc Mon Sep 17 00:00:00 2001 From: Artur Moreira Date: Tue, 12 May 2026 22:42:29 +0000 Subject: [PATCH] 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 --- docs/PERFORMANCE_BASELINE.md | 4 ++++ docs/deployment.md | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/PERFORMANCE_BASELINE.md b/docs/PERFORMANCE_BASELINE.md index aed8864..84896ed 100644 --- a/docs/PERFORMANCE_BASELINE.md +++ b/docs/PERFORMANCE_BASELINE.md @@ -56,6 +56,10 @@ Cache Rule applied to both zones via `deploy/scripts/cf-cache-rules-apply.sh` (` | 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](/BIT/issues/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). diff --git a/docs/deployment.md b/docs/deployment.md index 40037fc..d35e6ed 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -120,8 +120,8 @@ This is **board / DevOps configuration** in the Cloudflare dashboard (or API/Ter (http.host in {"andebol.net" "www.andebol.net"}) and not (http.request.uri.path contains "/wp-admin") and not (http.request.uri.path contains "/wp-login.php") and -not (http.request.uri.path starts_with "/wp-json/") and -not (http.request.uri.path starts_with "/api/") +not (http.request.uri.path contains "/wp-json/") and +not (http.request.uri.path contains "/api/") ``` **Zone `newsproject.bitreport.pt`:** @@ -131,16 +131,18 @@ not (http.request.uri.path starts_with "/api/") (http.host eq "newsproject.bitreport.pt") and not (http.request.uri.path contains "/wp-admin") and not (http.request.uri.path contains "/wp-login.php") and -not (http.request.uri.path starts_with "/wp-json/") and -not (http.request.uri.path starts_with "/api/") +not (http.request.uri.path contains "/wp-json/") and +not (http.request.uri.path contains "/api/") ``` +Use **`contains`** for path prefixes above (not `starts_with`) so expressions stay valid on **Cloudflare Free** (see `deploy/scripts/cf-cache-rules-apply.sh` notes from BIT-21912). + Extend the hostname list when new production hostnames are added under `config/domains/*.json`. The **`/api/`** exclusion reserves any future first-party API surface on the public hostname from edge HTML caching; adjust if a path must remain cacheable. 4. **Then** (cache settings): - **Cache eligibility:** **Eligible for cache** (this is the supported replacement for the legacy Page Rule “Cache Everything” for HTML; see Cloudflare’s doc [*Cache Level (Cache Everything)*](https://developers.cloudflare.com/cache/how-to/cache-rules/examples/cache-everything/)). - - **Edge TTL / origin behaviour:** leave **Origin Cache Control** effective so Cloudflare honours the Astro `s-maxage` / `stale-while-revalidate` headers (see [*Origin Cache Control*](https://developers.cloudflare.com/cache/concepts/cache-control/)). Do **not** set a fixed Edge TTL that overrides those values unless there is an explicit product decision. + - **Edge TTL / origin behaviour:** Prefer honouring origin `Cache-Control` / `s-maxage`. On some plans, HTML may still not edge-cache until **Edge TTL** is set (e.g. **override origin, 60 s**) in the same rule — the checked-in **`deploy/scripts/cf-cache-rules-apply.sh`** encodes what worked in production for BIT-21912. Re-evaluate if you upgrade plan or change cache semantics. 5. **Ordering:** place any **Bypass cache** rules (preview, authenticated staff, debug) **above** this rule so they win first. @@ -148,14 +150,14 @@ Extend the hostname list when new production hostnames are added under `config/d ### Verification (operator) -Second request should show a warm edge when the rule is active: +The cache rule matches **`GET`** only. **`curl -I` / `HEAD`** often shows **`cf-cache-status: DYNAMIC`** even when full **`GET`** responses are **`HIT`** — always verify with **GET** (body discarded): ```bash -curl -fsSI "https://andebol.net/" | tr -d '\r' | egrep -i '^(cf-cache-status|cache-control|age):' -curl -fsSI "https://andebol.net/" | tr -d '\r' | egrep -i '^(cf-cache-status|cache-control|age):' +curl -fsS "https://andebol.net/" -D - -o /dev/null | tr -d '\r' | egrep -i '^(cf-cache-status|cache-control|age):' +curl -fsS "https://andebol.net/" -D - -o /dev/null | tr -d '\r' | egrep -i '^(cf-cache-status|cache-control|age):' ``` -Expect `cf-cache-status: HIT` (or `STALE` / `REVALIDATED` per Cloudflare semantics) on the repeat, and `cache-control` unchanged from origin. Until the rule exists, both calls return **`DYNAMIC`** despite valid `Cache-Control`. +Expect `cf-cache-status: HIT`, `EXPIRED`, `STALE`, or `REVALIDATED` on the repeat (not bare `MISS` every time once warm), and `cache-control` from origin unchanged. If both passes stay **`DYNAMIC`** on **GET**, the rule is missing, disabled, or superseded by a higher-priority bypass rule. ---