Telemetry edge Stale-While-Revalidate caching headers across API routes #40

Closed
opened 2026-10-14 22:28:35 +00:00 by yuris · 1 comment
Owner

What to build

Configure edge caching headers across dynamic Next.js API routes (/api/hotspots, /api/tmat, /api/daops) to enable Stale-While-Revalidate caching at the CDN edge. Deliver sub-25ms telemetry responses to clients while refreshing data asynchronously in the background.

Technical specifications

  1. Target files:
    • src/app/api/hotspots/route.ts
    • src/app/api/tmat/route.ts
    • src/app/api/daops/route.ts
  2. Header configuration:
    • Cache-Control: public, s-maxage=600, stale-while-revalidate=120.
    • Vary: Accept-Encoding.

Acceptance criteria

  • Repeated GET requests to /api/hotspots return CF-Cache-Status: HIT or REVALIDATED.
  • TTFB for telemetry endpoints drops below 30ms on CDN cache hits.
  • External upstream API failure does not disrupt client access while stale cache is valid.

Authoritative Specifications & Reference Documentation

  • Titik Gambut Architecture & Subsystem Contract: docs/ARCHITECTURE.md
  • Peraturan Pemerintah No. 71/2014 jo PP 57/2016: PP 71/2014 & PP 57/2016 — Indonesian statutory standard mandating peat water table depth >= -0.4m (-40 cm).
  • BRGM Real-Time Peat Groundwater (TMAT) Sensors: PRIMS TMAT Monitoring — Telemetry groundwater data.
  • KLHK SiPongi+ Hotspot & Karhutla Command: sipongi.menlhk.go.id — Official active fire detection, Manggala Agni DAOPS operational stations, and field suppression records.
  • Manggala Agni Daops Directory: Ditjen PPI KLHK — Directory of 37 operational regions across Sumatra and Kalimantan.
  • Cloudflare R2 Object Storage: developers.cloudflare.com/r2 — Zero-egress HTTP 206 byte-range object storage.
  • Cloudflare CDN Cache-Control: developers.cloudflare.com/cache — Edge caching and Range header behavior.
### What to build Configure edge caching headers across dynamic Next.js API routes (`/api/hotspots`, `/api/tmat`, `/api/daops`) to enable Stale-While-Revalidate caching at the CDN edge. Deliver sub-25ms telemetry responses to clients while refreshing data asynchronously in the background. ### Technical specifications 1. **Target files**: - `src/app/api/hotspots/route.ts` - `src/app/api/tmat/route.ts` - `src/app/api/daops/route.ts` 2. **Header configuration**: - `Cache-Control: public, s-maxage=600, stale-while-revalidate=120`. - `Vary: Accept-Encoding`. ### Acceptance criteria - [ ] Repeated GET requests to `/api/hotspots` return `CF-Cache-Status: HIT` or `REVALIDATED`. - [ ] TTFB for telemetry endpoints drops below 30ms on CDN cache hits. - [ ] External upstream API failure does not disrupt client access while stale cache is valid. --- ### Authoritative Specifications & Reference Documentation - **Titik Gambut Architecture & Subsystem Contract**: [`docs/ARCHITECTURE.md`](https://git.nokopia.com/yuris/titik-gambut-next/src/branch/main/docs/ARCHITECTURE.md) - **Peraturan Pemerintah No. 71/2014 jo PP 57/2016**: [PP 71/2014 & PP 57/2016](https://peraturan.bpk.go.id/Details/41517/pp-no-71-tahun-2014) — Indonesian statutory standard mandating peat water table depth >= -0.4m (-40 cm). - **BRGM Real-Time Peat Groundwater (TMAT) Sensors**: [PRIMS TMAT Monitoring](https://prims.brgm.go.id/) — Telemetry groundwater data. - **KLHK SiPongi+ Hotspot & Karhutla Command**: [sipongi.menlhk.go.id](https://sipongi.menlhk.go.id/) — Official active fire detection, Manggala Agni DAOPS operational stations, and field suppression records. - **Manggala Agni Daops Directory**: [Ditjen PPI KLHK](http://ditjenppi.menlhk.go.id/) — Directory of 37 operational regions across Sumatra and Kalimantan. - **Cloudflare R2 Object Storage**: [developers.cloudflare.com/r2](https://developers.cloudflare.com/r2/) — Zero-egress HTTP 206 byte-range object storage. - **Cloudflare CDN Cache-Control**: [developers.cloudflare.com/cache](https://developers.cloudflare.com/cache/) — Edge caching and Range header behavior.
yuris changed title from Issue 27: [Backend] Telemetry edge Stale-While-Revalidate caching headers across API routes to [Backend] Telemetry edge Stale-While-Revalidate caching headers across API routes 2026-10-14 22:31:29 +00:00
yuris changed title from [Backend] Telemetry edge Stale-While-Revalidate caching headers across API routes to Telemetry edge Stale-While-Revalidate caching headers across API routes 2026-10-14 22:38:34 +00:00
Author
Owner

This was generated by AI during triage.

Closed as completed in main (edge SWR caching headers active across /api/hotspots, /api/tmat, /api/weather, /api/health).

> *This was generated by AI during triage.* Closed as completed in main (edge SWR caching headers active across /api/hotspots, /api/tmat, /api/weather, /api/health).
yuris closed this issue 2026-10-15 01:26:11 +00:00
Sign in to join this conversation.
No labels
backend
frontend
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/titik-gambut-next#40
No description provided.