Overview
The High IQ API uses a multi-tier caching system that automatically classifies endpoints and applies appropriate cache strategies. Caching is handled at both the CDN (Vercel Edge) and browser levels using standard HTTP cache headers, ETags, and stale-while-revalidate directives.Cache Tiers
Endpoints are automatically classified into one of eight endpoint types, each with its own caching strategy:Endpoint Classification
The cache classifier uses URL pattern matching to determine the endpoint type. OnlyGET requests are cached. All other HTTP methods (POST, PUT, DELETE, etc.) bypass the cache entirely.
- Static
- Catalog
- Detail
- Search
- Realtime (No Cache)
Rarely-changing content:
Cache-Control Headers
The API buildsCache-Control headers dynamically based on the endpoint classification:
Header Components
Example Headers by Endpoint Type
- Catalog
- Detail
- User Data
- Realtime
ETag Support
The API supports both strong and weak ETags for conditional requests:Conditional Requests
Clients can sendIf-None-Match headers to check if their cached version is still valid:
Conditional Response Optimization
The caching middleware inspects response content and adjusts headers dynamically:
An
X-Item-Count header is added to list responses:
YouTube Video Cache
YouTube video data uses a specialized 30-day cache in Supabase to optimize YouTube API quota usage (10,000 units/day limit).Cache Invalidation
Write operations (POST, PUT, PATCH, DELETE) automatically trigger cache invalidation for related content:
Invalidation tags are sent via the
X-Cache-Invalidate response header for CDN integration:
Cache Warming
The API includes proactive cache warming that triggers on approximately 0.1% of requests. It pre-populates cache entries for popular endpoints to reduce cold-cache latency for common queries.Cache Analytics
Cache performance is tracked internally with hit/miss/bypass counts per endpoint type. In development, analytics are periodically logged:X-Cache-Status header indicates the cache outcome:
