Skip to content

feat(server): support static asset byte ranges#2711

Open
Boyeep wants to merge 4 commits into
cloudflare:mainfrom
Boyeep:feat/static-byte-ranges
Open

feat(server): support static asset byte ranges#2711
Boyeep wants to merge 4 commits into
cloudflare:mainfrom
Boyeep:feat/static-byte-ranges

Conversation

@Boyeep

@Boyeep Boyeep commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What changed

  • support single bytes ranges in the Node production static server
  • return correct 206 Partial Content and 416 Range Not Satisfiable responses
  • support strong ETag and HTTP-date If-Range validation
  • serve ranges from the identity representation
  • advertise Accept-Ranges and emit Last-Modified
  • cover both startup-cache and filesystem fallback paths

Why

The Node production server ignored Range, unlike Next.js static serving. Large emitted media and other static assets could only be downloaded in full, preventing efficient seeking and resumable transfers.

Impact

Node deployments can serve bounded, open-ended, and suffix byte ranges. HEAD continues to ignore Range as required by RFC 9110, and normal compression behavior is unchanged for non-range requests.

Validation

  • vp test run tests/http-range.test.ts tests/static-file-cache.test.ts
  • vp test run tests/app-router-production-server.test.ts -t "serves static asset byte ranges"
  • vp check tests/http-range.test.ts tests/static-file-cache.test.ts tests/app-router-production-server.test.ts packages/vinext/src/server/http-range.ts packages/vinext/src/server/static-file-cache.ts packages/vinext/src/server/prod-server.ts

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2711
npm i https://pkg.pr.new/create-vinext-app@2711
npm i https://pkg.pr.new/@vinext/types@2711
npm i https://pkg.pr.new/vinext@2711

commit: 08a4f00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5271927a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +58 to +59
const timestamp = Date.parse(trimmed);
return Number.isFinite(timestamp) && Math.floor(mtimeMs / 1000) * 1000 <= timestamp;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject non-HTTP dates before honoring If-Range

If-Range only permits an HTTP-date, but Date.parse() also accepts formats such as 12/31/2099 and 2099-12-31. A client resuming an older download with such an invalid future validator will therefore receive 206 bytes from the current file instead of the required full 200 response, potentially combining bytes from different file versions. Validate the HTTP-date grammar before comparing the timestamp.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 08a4f00 against base 05eee9f using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 132.4 KB 132.4 KB ⚫ -0.0%
Client entry size (gzip) vinext 119.7 KB 119.7 KB ⚫ -0.0%
Dev server cold start vinext 2.85 s 2.84 s ⚫ -0.4%
Production build time vinext 3.14 s 3.10 s ⚫ -1.1%
RSC entry closure size (gzip) vinext 103.3 KB 103.3 KB ⚫ 0.0%
Server bundle size (gzip) vinext 177.8 KB 177.8 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@Boyeep
Boyeep force-pushed the feat/static-byte-ranges branch from 3988cd5 to 4db2e69 Compare July 26, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant