Offline range-request Service Worker caching engine (public/sw.js) #41

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

What to build

Implement the core service worker script (public/sw.js) to intercept MapLibre pmtiles:// range requests and telemetry endpoints, storing accessed chunk ranges in browser CacheStorage / IndexedDB with synthetic multi-range assembly.

Technical specifications

  1. Target files:
    • public/sw.js: Headless service worker script.
  2. Engine mechanics:
    • Intercept fetch requests matching /tiles/*.pmtiles and Anycast CDN tile host.
    • Cache individual byte range chunks keyed by ${url}#${start}-${end}.
    • Respond from cache when offline, reconstructing 206 Partial Content payloads.

Acceptance criteria

  • Service worker intercepts range requests cleanly without corrupting binary PBF chunks.
  • When offline, previously visited spatial extents resolve from cache storage with HTTP 206.
  • Zero UI dependencies; strictly an execution script for the service worker scope.

Authoritative Specifications & Reference Documentation

### What to build Implement the core service worker script (`public/sw.js`) to intercept MapLibre `pmtiles://` range requests and telemetry endpoints, storing accessed chunk ranges in browser `CacheStorage` / `IndexedDB` with synthetic multi-range assembly. ### Technical specifications 1. **Target files**: - `public/sw.js`: Headless service worker script. 2. **Engine mechanics**: - Intercept fetch requests matching `/tiles/*.pmtiles` and Anycast CDN tile host. - Cache individual byte range chunks keyed by `${url}#${start}-${end}`. - Respond from cache when offline, reconstructing 206 Partial Content payloads. ### Acceptance criteria - [ ] Service worker intercepts range requests cleanly without corrupting binary PBF chunks. - [ ] When offline, previously visited spatial extents resolve from cache storage with HTTP 206. - [ ] Zero UI dependencies; strictly an execution script for the service worker scope. --- ### 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) - **Protomaps PMTiles Specification**: [protomaps/PMTiles GitHub](https://github.com/protomaps/PMTiles) — cloud-optimized single-file vector/raster tile format using HTTP 206 byte-range requests. - **Protomaps Basemaps Style & Docs**: [protomaps.com/docs](https://docs.protomaps.com/basemaps/) - **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 28: [Backend] Offline range-request Service Worker caching engine (public/sw.js) to [Backend] Offline range-request Service Worker caching engine (public/sw.js) 2026-10-14 22:31:28 +00:00
yuris changed title from [Backend] Offline range-request Service Worker caching engine (public/sw.js) to Offline range-request Service Worker caching engine (public/sw.js) 2026-10-14 22:38:34 +00:00
Author
Owner

This was generated by AI during triage.

Closed as completed in PR #98 (public/sw.js implements HTTP 206 reconstruction & offline telemetry caching).

> *This was generated by AI during triage.* Closed as completed in PR #98 (public/sw.js implements HTTP 206 reconstruction & offline telemetry caching).
yuris closed this issue 2026-10-15 01:26:12 +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#41
No description provided.