Skip to content

perf(api): keep the live link item list in KV instead of the Cache API - #1087

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/live-link-index-kv
Oct 5, 2026
Merged

Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/live-link-index-kv

Conversation

@zachdunn

Copy link
Copy Markdown
Member

The item list cache from #1083 used the Workers Cache API. Public item pages (/c/<id>/<item>) reach the API through the web Worker's API service binding, and on that path the cache never produced a hit. Requests sent straight to api.uploads.sh did hit. Every real item page view still scanned and hashed the whole scope.

Changes

  • live-link-index.ts stores each live link's hashed scope list in a new LIVE_LINK_INDEX KV namespace with a 60 s expirationTtl (KV's minimum). The rest of the design is unchanged: a cached entry is used only after scopeHasKey confirms the key is still in scope, an id missing from the list costs one bounded query for newer rows, and a revoked link 404s before the lookup runs.
  • Production and preview use separate namespaces (UPLOADS_LIVE_LINK_INDEX, UPLOADS_LIVE_LINK_INDEX_PREVIEW), already created. The list holds object keys, so it is not shared the way GITHUB_CACHE is.
  • The route passes the binding into publicFeedItemPage, so the MCP Worker, which imports feed-service.ts without this binding, still type-checks and simply scans.
  • Each lookup logs one line, {"message":"live_link_index","outcome":...}, with hit, absent, stale, newer, miss, or unbound, so cache behaviour shows in Workers Logs.
  • Removes the Cache API test fake.

Testing

  • The existing cache tests now run against the KV fake: a cached hit with no rescan, an unknown id with one bounded query, a file added after caching, a deleted file never served, a file made private comes back withheld, live links not sharing a list, a revoked link, and TTL expiry. With the binding removed, 5 of them fail.
  • API tests (3115), repo-wide typecheck, and pnpm check pass.

After deploy, check Workers Logs for live_link_index lines with outcome: "hit" on /c/ page views.

Closes #1072

Public item pages reach the API through the web Worker's service binding,
where Cache API writes never produced a hit. The hashed scope list now
lives in a dedicated LIVE_LINK_INDEX KV namespace with a 60 s TTL, with the
same D1 checks before any cached entry is used. Each lookup logs its
outcome (hit, absent, stale, newer, miss, unbound).
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (2)
  • coderabbit:review
  • review
🚫 Excluded labels (none allowed) (1)
  • wip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4199d2d8-0550-4ec1-951c-e6ba8fd03208

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@changeset-bot

changeset-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5aa68c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
uploads-api 5aa68c8 Commit Preview URL

Branch Preview URL
Oct 05 2026, 12:37 PM

@zachdunn
Zach Dunn (zachdunn) merged commit 400cdc8 into main Oct 5, 2026
4 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the claude/live-link-index-kv branch October 5, 2026 12:39
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.

Cache or index the public live link item lookup

1 participant