mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #641] [MERGED] perf: build-time precompression + startup metadata cache for static serving #737
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#737
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/641
Author: @NathanDrake2406
Created: 3/22/2026
Status: ✅ Merged
Merged: 4/1/2026
Merged by: @james-elicx
Base:
main← Head:perf/precompressed-static-serving📝 Commits (10+)
0c7f808perf: add build-time precompression for hashed static assets91dc43cperf: add startup metadata cache for zero-syscall static serving0b83607perf: refactor tryServeStatic to async + cache + precompressed serving53f19d2docs: fix stale comments in precompress (mention .zst)078746dfix: deduplicate buffer reads for HTML alias entries, fix stale JSDocbd0ea02docs: fix stale comment in cli.ts (mention zstd)320466efix: address code review findings6b4b1e1fix: address remaining review findings in prod-servera623e58perf: move precompression to Vite plugin with edge auto-detection5b02a94docs: fix inaccurate comments in precompress and static-file-cache📊 Changes
8 files changed (+2043 additions, -80 deletions)
View changed files
➕
packages/vinext/src/build/precompress.ts(+160 -0)📝
packages/vinext/src/cli.ts(+8 -0)📝
packages/vinext/src/index.ts(+106 -0)📝
packages/vinext/src/server/prod-server.ts(+266 -80)➕
packages/vinext/src/server/static-file-cache.ts(+323 -0)➕
tests/precompress.test.ts(+195 -0)➕
tests/serve-static.test.ts(+668 -0)➕
tests/static-file-cache.test.ts(+317 -0)📄 Description
This PR implements a static file serving method that is better than Next.js 16.2.
Bugs fixed
existsSync+statSyncran on every static file request, blocking SSR responses behind synchronous filesystem calls. Now zero FS calls per request (metadata cached at startup).If-None-Matchsupport. Every repeat visit re-downloaded every asset in full. Now returns 304 (200 bytes) when the browser already has the asset.Optimizations
.br(brotli q5),.gz(gzip l8),.zst(zstd l8) generated at build time. Zero compression CPU per request. Enable viaprecompress: trueor--precompressCLI flag.res.end(buffer)instead ofcreateReadStream().pipe(), eliminating file descriptor overhead..zstassets. 3-5x faster client-side decompression than brotli (Chrome 123+, Firefox 126+).fsp.stat()instead of blockingstatSync.Real-world impact
Benchmark (100 assets, median of 5 runs)
fumadocs-docs-template build time
Feature comparison
sirvsendstat)existsSync+statSync)Architecture
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.