Skip to content

D3: prove the cache skips the DB read and keeps freshness — on production (#234) #240

Description

@xenodeve

Part of #234 · PRD: docs/prd/2026-07-26-public-read-latency-and-cache-strategy.md (D3) · depends on #238, #239

EN

Prove on production that the cache does what it claims. This slice exists because the previous attempt at this problem (#207, shipped in #233) produced a better number while the underlying work still happened on every request — a per-process memo took /projects from 3.2–3.7 s to 1.4–1.6 s and was mistaken for progress toward sub-second until it was measured properly.

A faster number is not evidence. Two things must be shown separately:

  1. The read was skipped, not merely faster. A warm request must demonstrably not reach Supabase.
  2. Freshness still holds. A write must appear well inside the ≤10-minute target.

Also worth settling here, because it is currently an assertion rather than a measurement: three independent agents stated that unstable_cache on Vercel is backed by a durable cross-invocation Data Cache rather than per-process memory. That is consistent with the Next docs ("persist the result across requests and deployments") but has not been verified on this deployment. If it turns out not to hold, #238's fallback keeps the page correct and the whole approach collapses back to #234's D4 decision.

Acceptance criteria

  • evidence that a warm request does not query Supabase (query log, an added counter, or an equivalent observation) — not a latency figure
  • warm p95 for /projects under 1 s, measured on production with the number recorded here
  • cache durability across invocations verified explicitly, or its failure recorded as a finding
  • a post-write probe: mutate → trigger revalidation → the next request shows the change, well under 10 minutes
  • x-vercel-cache is expected to stay MISS — the route is still dynamic. State that plainly so the result is not read as a failure
  • the measured numbers are posted on perf(projects): /projects and /blog are dynamic because they read searchParams — and no ADR records the caching strategy #234 and in the ledger, replacing the estimates

TH

ส่วนหนึ่งของ #234 · PRD: docs/prd/2026-07-26-public-read-latency-and-cache-strategy.md (D3) · ขึ้นกับ #238, #239

พิสูจน์บน production ว่าแคชทำสิ่งที่มันอ้าง slice นี้มีอยู่เพราะความพยายามครั้งก่อนกับปัญหานี้ (#207 ship ใน #233) ให้ ตัวเลขที่ดีขึ้น ขณะที่งานเบื้องหลังยังเกิดทุก request — memo ต่อ process ทำ /projects จาก 3.2–3.7 วิ เหลือ 1.4–1.6 วิ และถูกเข้าใจว่าเป็นความคืบหน้าไปสู่ sub-second จนกระทั่งวัดอย่างถูกต้อง

ตัวเลขที่เร็วขึ้นไม่ใช่หลักฐาน ต้องแสดงสองอย่างแยกกัน:

  1. การอ่านถูกข้าม ไม่ใช่แค่เร็วขึ้น request ที่ warm ต้องพิสูจน์ได้ว่าไม่ไปถึง Supabase
  2. ความสดใหม่ยังอยู่ การเขียนต้องปรากฏภายในเป้า ≤10 นาทีอย่างสบาย

อีกเรื่องที่ควรตัดสินที่นี่ เพราะตอนนี้เป็นการอ้างไม่ใช่การวัด: เอเจนต์อิสระสามตัวระบุว่า unstable_cache บน Vercel อยู่บน Data Cache ที่ durable ข้าม invocation ไม่ใช่ memory ต่อ process ซึ่งสอดคล้องกับ docs ของ Next ("persist the result across requests and deployments") แต่ ยังไม่ถูกยืนยัน บนดีพลอยนี้ ถ้าปรากฏว่าไม่จริง ตัว fallback ของ #238 จะทำให้หน้ายังถูกต้อง และแนวทางทั้งหมดจะยุบกลับไปที่การตัดสินใจ D4 ของ #234

เกณฑ์รับงาน

  • หลักฐานว่า request ที่ warm ไม่ query Supabase (query log, counter ที่เพิ่ม หรือการสังเกตที่เทียบเท่า) — ไม่ใช่ตัวเลขเวลา
  • p95 ตอน warm ของ /projects ต่ำกว่า 1 วินาที วัดบน production และบันทึกเลขไว้ที่นี่
  • ยืนยันความ durable ข้าม invocation อย่างชัดเจน หรือบันทึกความล้มเหลวของมันเป็นข้อค้นพบ
  • probe หลังการเขียน: แก้ข้อมูล → สั่ง revalidate → request ถัดไปเห็นการเปลี่ยนแปลง ต่ำกว่า 10 นาทีมาก
  • x-vercel-cache คาดว่าจะยังเป็น MISS — route ยังเป็น dynamic ระบุให้ชัดเพื่อไม่ให้อ่านผลว่าล้มเหลว
  • เลขที่วัดได้ถูกโพสต์บน perf(projects): /projects and /blog are dynamic because they read searchParams — and no ADR records the caching strategy #234 และใน ledger แทนค่าประมาณ

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions