Skip to content

Comments

feat: add Redis-backed cache proxy for search and resolver endpoints#805

Draft
thostetler wants to merge 1 commit intoadsabs:masterfrom
thostetler:feat/redis-cache-proxy
Draft

feat: add Redis-backed cache proxy for search and resolver endpoints#805
thostetler wants to merge 1 commit intoadsabs:masterfrom
thostetler:feat/redis-cache-proxy

Conversation

@thostetler
Copy link
Member

Client-side search and resolver requests were hitting the upstream API
directly on every page load with no server-side caching layer. This
adds a Redis-backed cache proxy that sits between the browser and the
upstream Solr/resolver APIs.

  • Add /api/proxy/[...path] catch-all route with session validation, origin check, rate limiting, and path allowlist
  • Add Redis singleton (ioredis) with lazy init, health tracking, and graceful degradation
  • Add cache-aside pattern: check Redis first, forward upstream on miss, cache 2xx responses
  • Wire client-side search and resolver hooks to route through the proxy
  • Flatten array query params (fl, sort) to comma-separated strings for Solr compatibility
  • Cache key format: scix:cache:GET:/path?sorted-params with 5min TTL
  • Add 27 unit tests covering proxy handler, cache key builder, param flattener, and Redis singleton

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 69.75477% with 111 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.6%. Comparing base (968d8a6) to head (8f24b3a).

Files with missing lines Patch % Lines
src/pages/api/proxy/[...path].ts 68.8% 43 Missing and 1 partial ⚠️
src/api/search/search.ts 16.7% 25 Missing ⚠️
src/lib/serverside/absCanonicalization.ts 66.7% 25 Missing ⚠️
src/lib/redis.ts 79.7% 13 Missing ⚠️
src/api/resolver/resolver.ts 71.5% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #805     +/-   ##
========================================
+ Coverage    61.6%   61.6%   +0.1%     
========================================
  Files         312     315      +3     
  Lines       36000   36320    +320     
  Branches     1594    1649     +55     
========================================
+ Hits        22148   22355    +207     
- Misses      13815   13927    +112     
- Partials       37      38      +1     
Files with missing lines Coverage Δ
src/lib/proxy-cache.ts 100.0% <100.0%> (ø)
src/api/resolver/resolver.ts 74.5% <71.5%> (-22.7%) ⬇️
src/lib/redis.ts 79.7% <79.7%> (ø)
src/api/search/search.ts 43.5% <16.7%> (-1.6%) ⬇️
src/lib/serverside/absCanonicalization.ts 60.7% <66.7%> (-2.4%) ⬇️
src/pages/api/proxy/[...path].ts 68.8% <68.8%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thostetler thostetler force-pushed the feat/redis-cache-proxy branch 2 times, most recently from cda6998 to d60b340 Compare February 15, 2026 05:34
Adds a server-side cache proxy that stores upstream API responses in
Redis for configurable TTLs. Client-side search and resolver requests
route through the proxy. Abstract SSR uses the same cache layer.

Includes origin validation, rate limiting, cache status headers, and
a dev-only hit/miss indicator.
@thostetler thostetler force-pushed the feat/redis-cache-proxy branch from d60b340 to 8f24b3a Compare February 15, 2026 05:38
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