Repository navigation
Conversation
Select .build/compress-assets.mjs from @MrAlders0n's Beacon change and carry its original LICENSE into scripts/static/beacon/. Process one asset at a time to bound compressor memory during packaging. Caddy serves the resulting sidecars alongside their canonical originals. Source: MeshCore-Beacon/beacon-web@68fd615 (cherry picked from commit 68fd61574b6cc6559e32e5285a650cbab87dc7e3)
|
Kent Beck Gate: PASS (test quality) at |
zfouts
left a comment
There was a problem hiding this comment.
Reviewed at adbcf1c9. Approving. The ordering is right and the test proves it.
- Compression runs last in
scripts/static/build.sh, after the__BUST__/__CORESCOPE_URL__fill, thedeployment.jsrewrite and the byte checks, so a sidecar can't be stale. test-static-build.jsdecodes every sidecar and compares it with a build withoutPRECOMPRESS. It would fail if compression ran before the substitutions.- Two
PRECOMPRESS=truebuilds give identical trees (diff -r, 132.br+ 132.gz). - Against Caddy 2.11.9 (what
apk add caddyinstalls on alpine:3.24) with this Caddyfile: correctContent-Encoding,Content-TypeandVary; a separate ETag per encoding; 304 for a matchingIf-None-Match; the@nocacheheaders still apply; andencodedoesn't re-compress a sidecar. test-static-build.js33/33 andtest-web-container.js10/10 pass locally.
Notes, none blocking:
- Licence (maintainer's call).
scripts/static/beacon/compress-assets.mjsis AGPL-3.0-or-later and brings a 661-line AGPLLICENSEinto this GPLv3 repo. GPLv3 §13 allows that, and the script is a build tool that is never served, but the maintainer should accept it deliberately. A clean-room rewrite of the ~35 lines would avoid the question. - Caddy version.
Dockerfile.webdoesn't pin Caddy. With this Caddyfile,caddy:2.10.2answers a plain GET (no Range header) with 206 whenever a sidecar exists; 2.11.9 is fine. A comment indocker/web/Caddyfilenaming the minimum version would save someone reusing it. - Cloudflare limits. The file-count and 25 MiB checks (
build.sh:134-138) run before compression, soPRECOMPRESS=truewith a Pages deploy (about double the files, and Pages ignores the sidecars) isn't checked. DocumentingPRECOMPRESSas web-image-only, or refusing it unlessAPI_BASE=same-origin, would close that.
|
Following up on the licence note in my review: n30nex#31 is a PR into this branch. It replaces
If you merge it into |
|
Thanks @n30nex. The packaging itself looks right: only One thing before merging: CoreScope is GPL-3.0, and I'd rather keep a single licence in the repo than carry an AGPL-3.0 file with its own LICENSE under Non-blocking, for this PR or a follow-up:
|
Closes #2505.
The split web image prepares Brotli and gzip sidecars after writing its deployment descriptor and cache-busted HTML. Caddy negotiates the sidecars. Dynamic encoding remains available for other responses. Node.js is confined to the image’s packaging stage.
This is a selective cherry-pick of Beacon’s precompression commit. The standalone
.build/compress-assets.mjstool now lives inscripts/static/beacon/, with its original AGPL-3.0-or-later license, author credit and commit trailer. The adaptation processes one file at a time. The ordinary static build still succeeds without Node.Across 144 identical packaged files, actual Caddy HTTP response body totals were:
All 1,152 responses decoded to the original bytes. The 264 sidecars added 3,006,398 bytes. Median packaging time over three runs rose from 0.44 s to 13.03 s. The browser-profile transfer reduction was 19.4% across the full asset set.
Verified with Alpine Caddy, Edge, 33 packaging tests and 10 web-container checks. Tests before the fix