Skip to content

fix(pages): send Purpose: prefetch on static page-data prefetch - #1065

Closed
Brooooooklyn wants to merge 2 commits into
mainfrom
fix/pages-prefetch-purpose-header
Closed

Brooooooklyn wants to merge 2 commits into
mainfrom
fix/pages-prefetch-purpose-header

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

The dynamic page-data prefetch already sends Purpose: prefetch. The static /_void/pages/*.json prefetch didn't, so the server couldn't tell it apart from a real visit. Visit analytics (coming next) needs that difference so it doesn't count hover prefetches as page views.

prefetch() / stale-entry refresh
   ├─ fast path:  static JSON ............................ Purpose: prefetch  (new)
   └─ dynamic GET X-VoidPages ............................ Purpose: prefetch  (unchanged)
         └─ HTML with deferred props ─► static JSON ...... Purpose: prefetch  (new)

visit()  ─ any path ...................................... no Purpose
  • Only the two calls inside fetchPrefetchPageData pass 'prefetch'. Visits pass nothing, and no new request is added.
  • Caching: nothing Void serves sends Vary: Purpose, so a prefetched file and a later visit still share one cache entry.
  • The framework adapters have no fetch of their own; they all call engine.prefetch().

Tests

packages/void/test/unit/pages-client.test.ts:

  • The static/dynamic test now checks the header: prefetch on a prefetch, none on a visit.

  • A new table test covers the HTML-first path, with the fast path off and on. Removing purpose, or forcing it on visits, each makes a case fail.

  • Focused file: 163 passed

  • vp check: clean

  • vp run test: 200/200 tasks

🤖 Generated with Claude Code

Brooooooklyn and others added 2 commits December 6, 2026 18:11
Dynamic X-VoidPages prefetch already sends Purpose: prefetch, but the
static /_void/pages/*.json fetch did not, both on the fast path and when
the HTML answer has deferred props. Pass the purpose through
loadStaticPageData and loadStaticPageDataFile so every prefetch request
says so, and a visit never does. The header does not change the static
file or its cache key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the fast-path static JSON fetch misses and the dynamic GET returns
HTML, loadStaticPageData fetches the static file again. Run the HTML-first
Purpose test with the fast path on too, so that retry must carry
Purpose: prefetch for a prefetch and no Purpose for a visit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T10:30:18.871504Z 9f29f50 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.

Worker Status Deployment Commit
void-cloud Deployed Preview 9f29f50

Updated: Dec 6, 2026, 10:29 UTC | Dashboard

@Brooooooklyn Brooooooklyn mentioned this pull request Dec 6, 2026
7 tasks done
@Brooooooklyn

Copy link
Copy Markdown
Member Author

Combined into #1067 (visit analytics, one PR). All commits from this PR are on that branch.

@Brooooooklyn
Brooooooklyn deleted the fix/pages-prefetch-purpose-header branch December 6, 2026 12:15
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