[PR #434] [MERGED] perf: TTL-based eviction sweep for prefetch cache #572

Closed
opened 2026-05-06 13:08:49 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/434
Author: @Divkix
Created: 3/11/2026
Status: Merged
Merged: 3/11/2026
Merged by: @james-elicx

Base: mainHead: worktree-perf/prefetch-cache-ttl-sweep


📝 Commits (4)

  • 2d4bf89 perf: add TTL-based eviction sweep for prefetch cache
  • 968f133 fix: sync prefetched URL set on cache eviction
  • 32baeec Merge remote-tracking branch 'origin/main' into worktree-perf/prefetch-cache-ttl-sweep
  • 59b4064 fix: address review comments on prefetch cache TTL sweep

📊 Changes

3 files changed (+175 additions, -4 deletions)

View changed files

📝 packages/vinext/src/shims/navigation.ts (+21 -4)
📝 packages/vinext/src/shims/next-shims.d.ts (+1 -0)
tests/prefetch-cache.test.ts (+153 -0)

📄 Description

Closes #440

Summary

  • Adds a TTL sweep pass in storePrefetchResponse() that clears all expired entries before falling back to FIFO eviction, preventing expired entries from wasting cache slots on link-heavy pages
  • Exports MAX_PREFETCH_CACHE_SIZE from navigation.ts for testability
  • Adds 4 unit tests covering: all-expired sweep, FIFO fallback for fresh entries, mixed expired/fresh sweep, and no-sweep below capacity

Test plan

  • pnpm test tests/prefetch-cache.test.ts — 4/4 pass
  • pnpm test tests/shims.test.ts — 652/652 pass (no regressions)
  • pnpm run typecheck — clean
  • pnpm run lint — clean
  • pnpm run fmt:check — clean
  • CI full suite (Vitest + Playwright E2E) — all green

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/434 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `worktree-perf/prefetch-cache-ttl-sweep` --- ### 📝 Commits (4) - [`2d4bf89`](https://github.com/cloudflare/vinext/commit/2d4bf89eacdef7eaf0179514d8dcc36a1eedcdf9) perf: add TTL-based eviction sweep for prefetch cache - [`968f133`](https://github.com/cloudflare/vinext/commit/968f13319519cd945ee775cc7724d5570d04a040) fix: sync prefetched URL set on cache eviction - [`32baeec`](https://github.com/cloudflare/vinext/commit/32baeecc72cb161272d98e9eebd4ac877b6605e2) Merge remote-tracking branch 'origin/main' into worktree-perf/prefetch-cache-ttl-sweep - [`59b4064`](https://github.com/cloudflare/vinext/commit/59b4064d2a606b2a8fbc47fefa34932e4bb5e73e) fix: address review comments on prefetch cache TTL sweep ### 📊 Changes **3 files changed** (+175 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/shims/navigation.ts` (+21 -4) 📝 `packages/vinext/src/shims/next-shims.d.ts` (+1 -0) ➕ `tests/prefetch-cache.test.ts` (+153 -0) </details> ### 📄 Description Closes #440 ## Summary - Adds a TTL sweep pass in `storePrefetchResponse()` that clears all expired entries before falling back to FIFO eviction, preventing expired entries from wasting cache slots on link-heavy pages - Exports `MAX_PREFETCH_CACHE_SIZE` from `navigation.ts` for testability - Adds 4 unit tests covering: all-expired sweep, FIFO fallback for fresh entries, mixed expired/fresh sweep, and no-sweep below capacity ## Test plan - [x] `pnpm test tests/prefetch-cache.test.ts` — 4/4 pass - [x] `pnpm test tests/shims.test.ts` — 652/652 pass (no regressions) - [x] `pnpm run typecheck` — clean - [x] `pnpm run lint` — clean - [x] `pnpm run fmt:check` — clean - [x] CI full suite (Vitest + Playwright E2E) — all green --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:49 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#572
No description provided.