Using RxJS shareReplay as a Simple HTTP Cache in Angular Services
Learn how to apply shareReplay to avoid duplicate HTTP requests, set trust boundaries, check operation, and recognize when the design must evolve.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to apply shareReplay to avoid duplicate HTTP requests, set trust boundaries, check operation, and recognize when the design must evolve.
When several components need the same HTTP data, each subscription can fire a new request. RxJS’s shareReplay can multicast a single call and cache the result. This guide explains how to use shareReplay, shows a concrete example, discusses trade‑offs, and gives actionable steps for real‑world use.
Learn how to cache HTTP GET responses with RxJS shareReplay, configure bufferSize and refCount, avoid memory leaks, and handle stale data in Angular services.
Background URLCache's .returnCacheDataElseLoad policy serves a cached response if one exists, even when the entry is stale by HTTP freshness rules. When a response lacks explicit freshness headers such as Expires or Cache-Control: max-age , the cache applies an undocumented heuristic—approximately 10% of the time elapsed since the Date header—to decide wheth
I'm reviewing a Gatling simulation suite that was written against 3.9 and recently upgraded to 3.10. The tests hit state-dependent REST endpoints where each virtual user presents a session-specific token, and the payloads include timestamps that must be fresh on every iteration. My understanding is that before 3.10, the HTTP protocol cache was enabled by def
Goal Investigate how Gatling 3.7.0’s in‑memory HTTP cache responds to Cache‑Control directives when the responses traverse a reverse proxy that rewrites or drops headers. Constraints The cache is per‑host, limited by a configurable size, and invalidation is triggered only via the clearCache method. Proxies can modify Cache‑Control , ETag , or add Age , poten
Integration boundary: Angular HTTP wrapper + RxJS shareReplay I am wrapping HTTP calls in a shared service where multiple components subscribe to the same response stream, and I am using shareReplay to avoid duplicate requests. The documented config-object form, shareReplay({ bufferSize, refCount, windowTime }) , forces a decision I cannot resolve from the d