From f309f625532ec4c8a43c6cccedf5556e2defcda4 Mon Sep 17 00:00:00 2001 From: gnezim Date: Tue, 14 Apr 2026 21:37:43 +0300 Subject: [PATCH] Swap server LRU cache to lru-cache v10 for byte-based cap @isaacs/ttlcache has no byte cap (only count). A 100MB hard limit needs lru-cache v10's maxSize + sizeCalculation. Aligns design spec with Phase 1 master plan contract revision. --- .../specs/2026-04-14-aeroflot-flights-react-rewrite-design.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/superpowers/specs/2026-04-14-aeroflot-flights-react-rewrite-design.md b/docs/superpowers/specs/2026-04-14-aeroflot-flights-react-rewrite-design.md index 507f32a6..d3f5d795 100644 --- a/docs/superpowers/specs/2026-04-14-aeroflot-flights-react-rewrite-design.md +++ b/docs/superpowers/specs/2026-04-14-aeroflot-flights-react-rewrite-design.md @@ -386,7 +386,7 @@ No Axios. No TanStack Query. No SWR. Custom ~80-line cache keyed by full URL. TTL: 30s for search results, 5m for static reference data (airports, cities). Replaces the Angular `CacheService` directly. **Shared server-side LRU cache (per-VM).** -`@isaacs/ttlcache`, in-memory, ~100MB cap. Keyed by `(endpoint, queryParams, locale)`. TTL: 30s for live data, 5m for static data. Per-VM, not shared across VMs — no Redis in the frontend tier (adds failure modes). +`lru-cache@^10`, in-memory, ~100MB byte cap via `maxSize` + `sizeCalculation` (default sizer: `JSON.stringify(value).length`; callers may pass a pre-computed size hint from the response `content-length` to avoid O(n) sizing on write). Keyed by `(endpoint, queryParams, locale)`. TTL: 30s for live data, 5m for static data. Per-VM, not shared across VMs — no Redis in the frontend tier (adds failure modes). (`@isaacs/ttlcache` was considered but lacks byte-based caps — `lru-cache@^10`, also maintained by isaacs, is the correct primitive for a 100MB hard limit.) ### 4.3 SSR → client data handoff @@ -744,7 +744,7 @@ Cross-Origin-Resource-Policy: cross-origin **Mechanisms:** -1. **Loader-level caching** — per-request dedup + per-VM LRU (`@isaacs/ttlcache`, 100MB cap, 30s TTL live / 5m TTL static). +1. **Loader-level caching** — per-request dedup + per-VM LRU (`lru-cache@^10` with `maxSize` byte cap, 100MB cap, 30s TTL live / 5m TTL static). 2. **HTTP cache headers by route type:** | Route type | `Cache-Control` |