Skip to content

Raise catalog cache TTL to 24h and optimize global search - #711

Closed
tiankaima wants to merge 1 commit into
mainfrom
perf/cache-ttl-and-search-optimization
Closed

Raise catalog cache TTL to 24h and optimize global search#711
tiankaima wants to merge 1 commit into
mainfrom
perf/cache-ttl-and-search-optimization

Conversation

@tiankaima

Copy link
Copy Markdown
Member

Summary

  • Raise PUBLIC_DETAIL_RUNTIME_CACHE_TTL_MS and PUBLIC_DETAIL_KV_CACHE_TTL_MS from 60s/1h to 24h (revision-scoped keys still invalidate on static import).
  • Optimize /api/search by replacing paginated list summaries (COUNT + heavy includes) with lightweight findMany queries.
  • Add a 120s in-memory response cache keyed by locale + query + limit + user.

Motivation

Production metrics showed ~0.06% section KV hit rate and ~956ms avg search latency. The 60s L1 TTL was too short for high-cardinality section traffic; search was paying for COUNT queries and full summary includes on every request.

Test plan

Longer L1/KV TTL improves section KV hit rate for repeat traffic; search now skips COUNT queries and caches responses for 120s.
@cloudflare-workers-and-pages

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 Updated (UTC)
✅ Deployment successful!
View logs
life-ustc a49715e Jul 31 2026, 10:21 AM

@tiankaima

Copy link
Copy Markdown
Member Author

Closing as superseded by merged work on main.

Already in main via #712 (5bc4e4a5):

  • 24h catalog detail L1/KV TTL (PUBLIC_CATALOG_RUNTIME_CACHE_TTL_MS / PUBLIC_CATALOG_KV_CACHE_TTL_MS in catalog-runtime-cache.ts, re-exported from catalog-detail-runtime-cache.ts)
  • Global search query optimization (global-search-catalog-queries.ts — lightweight findMany instead of paginated list summaries with COUNT)
  • Catalog search caching via cachedCatalogRuntimeData (revision-scoped L1/KV/colo, 300s TTL) — supersedes this PR's simpler 120s in-memory global-search-response-cache.ts Map

Already in main via #713 (d4cde989):

  • GlobalSearchDialog lazy-load (client bundle / E2E budget)

This branch (a49715e) predates #712/#713 and now conflicts on global-search-service.ts, global-search-catalog-queries.ts, catalog-detail-runtime-cache.ts, and tests. No unique valuable changes remain to cherry-pick.

Related: #709 — TTL raise landed in #712; post-deploy KV hit-rate measurement still tracked there.

@tiankaima tiankaima closed this Aug 1, 2026
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