Skip to content

perf: Implement cache warming for top queries #573

@KevinTCoughlin

Description

@KevinTCoughlin

Summary

Pre-populate cache for popular search queries to reduce cold start latency.

Overview

Use a cron trigger to periodically fetch and cache results for the top N most popular queries.

Implementation Notes

  • Add cron trigger to wrangler.toml:
    [triggers]
    crons = ["0 * * * *"]  # Every hour
  • Use D1 trending data to identify top 50 queries
  • Pre-fetch search results for each query
  • Store in Cloudflare Cache API

Approach

  1. Query D1 for top 50 queries from the last 7 days
  2. For each query, make internal search request
  3. Results get cached automatically via existing caching logic
  4. Log cache warming metrics

Acceptance Criteria

  • Cron job runs hourly
  • Top 50 queries are pre-cached
  • Cache warming doesn't exceed rate limits
  • Metrics logged for monitoring
  • Tests added for cache warming logic

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions