post: Your service worker's precache can't do Range requests — PMTiles needs 206 - #51
Open
clarkbw wants to merge 1 commit into
Open
post: Your service worker's precache can't do Range requests — PMTiles needs 206#51clarkbw wants to merge 1 commit into
clarkbw wants to merge 1 commit into
Conversation
…s needs 206 Draft for review. Workbox precache serves a plain 200 with the full body and no Range support; pmtiles reads the archive with Range requests and requires 206, so a precached .pmtiles worked on the cold first visit and threw on every return visit. Fix is a CacheFirst runtimeCaching route with rangeRequests:true plus a non-ranged warm fetch, because RangeRequestsPlugin only implements cachedResponseWillBeUsed and a ranged request can never populate the cache. Three hand-written SVG figures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HaMaRk9UijJQMDX48EVvTk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Post: 2026-08-11-pmtiles-workbox-precache-range-requests-206-partial-content-service-worker-offline-maplibre-vite-plugin-pwa-runtimecaching-rangerequests-cachefirst.md
Draft — not published. The
date:is the draft date (2026-08-11); the publisher bumps date + filename at merge (script/bump.py/script/publish.py).What it covers
The
slackwater-webPWA fix in2e8c05f. Workbox's precache stores and replays a full200 OK;pmtilesreads the archive with HTTP Range requests and requires206 Partial Content. So a precachedland.pmtilesrendered on the cold first visit — when no service worker was in the path — and threw on every visit after, with the map screen blank offline.Arc: precache it (and hit the silent 2 MB
maximumFileSizeToCacheInBytescap) → a smoke test whose own comment named the bug and then ordered itself to avoid it →runtimeCaching+rangeRequests: true, which leaves the cache permanently empty → the fix.The load-bearing finding:
RangeRequestsPluginimplements onlycachedResponseWillBeUsed, so it never touches the outbound request. A ranged first read misses, hits the network, gets a206, andcacheableResponse: { statuses: [200] }refuses to store it — and you can't widen that, because the Cache API rejects a 206 onput(). Hence the non-ranged warm fetch inmain.tsx. Sub-gotcha:registerType: 'prompt'doesn't setclientsClaim, soserviceWorker.readyresolves whilecontrolleris still null — the warm fetch has to also listen forcontrollerchange.SEO targets
Slug/description/tags carry:
pmtiles,Server returned no content-length header or content-length exceeding request,Check that your storage backend supports HTTP Byte Serving,206 Partial Content,workbox precache range requests,rangeRequests: true,runtimeCaching,CacheFirst,cacheableResponse,maximumFileSizeToCacheInBytes,vite-plugin-pwa,registerType prompt,clientsClaim,controllerchange,maplibre,Partial response (status code 206) is unsupported.Figures (3, hand-written SVG)
first-visit-vs-return-visit.svg— the mechanism: same byte-range read, 206 from the static host vs 200 from the precache, and where pmtiles throws.cachefirst-range-deadlock.svg— why a ranged request can never fill aCacheFirstroute, and how the warm fetch breaks the loop.service-worker-control-timeline.svg—readyresolves beforecontrolleris set underregisterType: 'prompt'.Verification
python3 script/lint-liquid.py→post lint: 35 posts cleanbundle exec jekyll build→ clean<img src="/assets/img/…">present in_site/<slug>/index.html; SVGs land in_site/assets/img/<slug>/; bothpost_urlrelated links resolve.No
{% raw %}guard needed — the body has no{{/{%outside the related-links footer.Notes for review
FetchSource.getBytescheck (protomaps/PMTilesjs/src/index.ts) andworkbox-range-requests/src/RangeRequestsPlugin.ts(v7). Worth a glance since the post leans on both.slackwater-webcode.🤖 Generated with Claude Code
https://claude.ai/code/session_01HaMaRk9UijJQMDX48EVvTk