Skip to content

Full Project Analysis: RFC 9111 CDN Caching Proxy ​

0.1 What the Project Is ​

Purpose & Problem Solved ​

Modern web platforms handle massive volumes of static and dynamic HTTP traffic. Directing all client requests straight to backend application servers and databases causes:

  1. Origin Saturation: High load spikes (flash sales, breaking news) overwhelm application databases.
  2. Bandwidth Costs: Origin cloud egress bandwidth is expensive compared to edge caching tiers.
  3. Elevated Latency: Users located far from the origin experience high network round-trip delays.

17-cdn-caching-proxy is a standalone, RFC 9111 compliant reverse caching edge proxy. It intercepts HTTP traffic, validates caching rules, serves repeated requests directly from high-speed memory or local disk, coalesces simultaneous misses, and provides instant cache invalidation.

Target Users ​

  • Infrastructure & Platform Engineers: Deploying edge proxy layers to shield backend microservices.
  • CDN Operators: Requiring predictable, RFC-compliant caching behavior with granular purge control.
  • Site Reliability Engineers (SREs): Monitoring edge hit ratios, origin health, and bandwidth savings.

Main User & Request Journeys ​

  1. Cache Hit Journey: Client issues GET /images/logo.png. Proxy looks up the canonical hash key in MemoryStore, detects an unexpired entry, validates freshness, sets X-Cache: HIT, and pipes the cached stream directly to the client in under 1 millisecond.
  2. Cache Miss & Coalescing Journey: 500 concurrent clients request /catalog/item-42. Proxy detects a cache miss. Rather than flooding the origin with 500 requests, RequestCoalescer elects one request as leader. The leader forwards to origin, while 499 followers wait. When origin responds with 200 OK, the stream is tee-piped into the cache store and simultaneously fanned out to all 500 clients.
  3. Cache Purge Journey: An operator updates product data and issues POST /admin/api/v1/purge with tag category-electronics. PurgeIndex matches 200 cached items, marks them invalidated in memory, and records an immutable cryptographic SHA-256 audit entry.

0.2 Feature Architecture & Traces (F1 - F16) ​

The project implements 16 major architectural feature modules, covering 152 distinct verified capabilities:

Complete Feature Trace Table ​

Feature IDModule & NameKey Files InvolvedPrimary FunctionsData TouchedEndpoints Involved
F1RFC 9111 Cache Coresrc/proxy/request.ts, src/cache/lookup.ts, src/cache/serve.tsparseRequest, lookupCache, serveCacheHitCacheEntry, MemoryStoreGET /*, HEAD /*
F2Request Coalescingsrc/proxy/coalesce.ts, src/proxy/forward.tsjoinOrLead, resolveWaitersflightMap, passMarkerMapGET /*
F3Multi-Tier Storagesrc/cache/memory-store.ts, src/cache/disk-store.tsstore, get, compactSegmentsIn-memory Buffer, Disk segmentsInternal storage
F4Eviction Algorithmssrc/cache/eviction/lru.ts, lfu.ts, slru.ts, ttl.tsonAccess, evictNext, isTtlEvictableEviction lists, Frequency binsInternal storage
F5Revalidation & 304src/cache/revalidate.ts, src/cache/serve.tshandleRevalidationResponse, serveCache304CacheEntry.metadataGET /* (If-None-Match)
F6Tag Purge & Auditsrc/purge/api.ts, src/purge/index-store.ts, src/purge/audit.tspurgeByTag, appendAuditEntrytagMap, auditLog SHA-256 chainPOST /admin/api/v1/purge
F7Streaming Compressionsrc/compression/codecs.ts, src/compression/negotiate.tscreateCompressor, negotiateEncodingStream transformsGET /* (Accept-Encoding)
F8Range Partial Contentsrc/range/parse-range.ts, src/cache/large-object.tsparseRangeHeader, sliceStreamStream slicesGET /* (Range)
F9Multi-Origin & Circuitsrc/config/origins.ts, src/health/circuit-breaker.tsresolveOriginForRequest, recordFailureCircuitBreakerStateUpstream HTTP
F10Edge Security WAFsrc/security/ip.ts, src/security/host.ts, src/security/jwt.tsevaluateIpAccess, isHostAllowed, verifyTokenAllow/Deny sets, JWK keys/* (Ingress filter)
F11Observabilitysrc/observability/metrics.ts, src/observability/logger.tsrecordHit, recordMiss, logRequestPrometheus metrics countersGET /metrics
F12Admin Control Planesrc/admin/server.ts, src/admin/routes-manager.tshandle, addRoute, setPolicyRoute registry, Policy storeGET /admin, GET /admin/api/v1/*
F13Next.js Dashboardfrontend/app/dashboard/page.tsxDashboardPage, fetchMetrics, pollTimeseriesReact state, Rechartshttp://localhost:3000/dashboard
F14Consistent Hashingsrc/cluster/consistent-hashing.ts, src/cluster/peer-cluster.tsgetNode, forwardToPeerKetama ring, Virtual nodesPeer proxy mesh
F15Cache Pre-Warmingsrc/warm/warm-prefetch.tswarmUrls, prefetchLinkHeadersPre-warm queuePOST /admin/api/v1/warm
F16AIML Model Layeraiml/MODEL_CARD.md, eval/evaluate_model.pypredict_popularity, evaluateTelemetry logs, Metric tensorsAsync offline evaluation

0.3 Every API & Endpoint ​

Reverse Proxy Listener (Port 8080) ​

MethodPathAuthHandler FunctionPurpose
GET / HEAD/*Optional (API Key / JWT)handleProxyRequest (src/proxy/index.ts:180)Main reverse caching proxy pipeline
POST / PUT / DELETE/*OptionalforwardUncached (src/proxy/forward.ts:35)Pass-through non-idempotent mutations to origin
GET/metricsNonemetricsRegistry.toPrometheusText()Prometheus exposition text format (0.0.4)
GET/_healthNoneHealth check endpointReturns 200 OK for load balancers

Admin Control Plane (Port 9090) ​

MethodPathAuthHandler FunctionPurpose
GET/admin or /NonerenderDashboardHtmlServes embedded zero-dependency SPA dashboard HTML
GET/admin/api/v1/statusBearer TokenAdminServer.handle (src/admin/server.ts:131)Returns node health, uptime, and version
GET/admin/api/v1/overviewBearer TokenAdminServer.handle (src/admin/server.ts:145)Returns total cached objects, bytes, and hit ratio
GET/admin/api/v1/timeseries/:metricBearer TokenAdminServer.handle (src/admin/server.ts:166)Returns 1-hour time-series history points
GET/admin/api/v1/originsBearer TokenAdminServer.handle (src/admin/server.ts:174)Lists origin health, weights, and circuit breaker status
POST/admin/api/v1/origins/:id/drainBearer TokenAdminServer.handle (src/admin/server.ts:186)Marks an origin as drained for maintenance
POST/admin/api/v1/origins/:id/enableBearer TokenAdminServer.handle (src/admin/server.ts:194)Re-enables a previously drained origin
GET/admin/api/v1/routesBearer TokenRouteConfigurationManager.getRoutesRetrieves active routing table
POST/admin/api/v1/routesBearer TokenRouteConfigurationManager.addRouteInserts or updates dynamic route pattern
DELETE/admin/api/v1/routes/:idBearer TokenRouteConfigurationManager.deleteRouteRemoves a dynamic route
GET/admin/api/v1/policiesBearer TokenCachePolicyManager.getPoliciesRetrieves route/tenant cache policy overrides
POST/admin/api/v1/policiesBearer TokenCachePolicyManager.setPolicySets TTL, bypass, and revalidation policies
GET/admin/api/v1/tenantsBearer TokenMemoryStore.getTenantStatsReturns per-tenant byte usage and quota limits
GET/admin/api/v1/inspector/decisionsBearer TokenRequestInspector.getRecentDecisionsInspects recent caching decisions ring buffer
POST/admin/api/v1/purgeBearer TokenPurgeApiHandler.handleRequest (src/purge/api.ts)Executes URL, Prefix, Tag, Host, or Tenant purge
GET/admin/api/v1/purge/jobs/:idBearer TokenPurgeJobQueue.getJobStatusPolls status of async background purge job
GET/admin/api/v1/purge/auditBearer TokenPurgeAuditTrail.getEntriesRetrieves cryptographic audit log entries

0.4 Every Hook, Helper, and Shared Piece ​

Next.js Dashboard React Hooks (frontend/app/dashboard/page.tsx) ​

  • useState: Manages active telemetry metrics, origin lists, route tables, purge forms, and live charts.
  • useEffect: Sets up a periodic 1-second polling timer against http://localhost:9090/admin/api/v1/timeseries.
  • useCallback: Memoizes API fetchers (fetchOverview, fetchOrigins, submitPurge) to avoid unnecessary re-renders.

Key Shared Utilities & Helpers ​

  • src/util/clock.ts: Clock interface with SystemClock and MockClock for time travel in deterministic tests.
  • src/cache/key.ts: Canonical cache key builder normalizing query param order and appending Vary values.
  • src/cache/cache-control.ts: Fast parser for RFC 9111 Cache-Control directive tokens (max-age, s-maxage, no-cache, no-store).
  • src/observability/tracing.ts: W3C traceparent generator and propagator.
  • src/proxy/headers.ts: RFC 9110 hop-by-hop header scrubber (strips Connection, Keep-Alive, Proxy-Authenticate, Transfer-Encoding).

0.5 System Connection Map ​


0.6 Final Inventory Counts ​

Metric / CategoryExact Codebase CountVerification Source
Total Major Feature Modules16 ModulesGrouped F1 - F16 (docs/features/)
Total Granular Features152 FeaturesMaster list in FEATURES.md
Total Test Suites151 Suitestests/*.test.ts (1,064 tests)
Total Endpoints (Proxy & Admin)18 EndpointsDocumented in docs/03-api-reference.md
Frontend Screens / Views3 ViewsLanding, Next.js Dashboard, Embedded Admin SPA
Eviction Algorithms4 PoliciesLRU, LFU, SLRU, TTL (src/cache/eviction/)
Compression Codecs3 CodecsBrotli, Gzip, Zstandard (src/compression/)
Storage Engines2 TiersMemoryStore & DiskStore (src/cache/)