Fluxio
← Back to the blog

Cache Repeated Context for SSE Support Bot Token Streams

Build notesEN

§1 Repeated Context Inflates Every Token Stream in a Support Bot

Support bots resend a surprising amount of unchanged input on every turn, and that repetition is the biggest lever on both cost and latency in a live chat. A typical four-turn ticket carries a fixed system prompt, tone rules, a refund policy block, and a retrieval layer that keeps returning the same help-center chunks for common questions. In our replay corpus the boilerplate measured between 8,000 and 15,000 tokens per conversation, and about 70 percent of it was byte-identical from one turn to the next.

When replies arrive token by token, the pain shows up before the stream starts. Uncached context forces a full prefill pass on every request, so time to first token suffers even though the model spends most of its budget re-reading text it has already seen. Caching repeated context is therefore not only a cost optimization; it is the fastest way to shorten the silent gap between a user pressing Enter and the first visible token appearing in the widget.

  • – A shared system prompt of roughly 2,400 tokens that never changes between tickets
  • – A refund and escalation policy block repeated verbatim in every conversation
  • – A retrieval layer returning the same three help-center chunks for the top 20 intents
  • – A session memory block resent from scratch on every turn instead of being reused
  • – A tool schema and function description payload rebuilt identically for each request

§2 Field Test Setup: 2,000 Replayed Sessions on Real Support Traffic

We replayed 2,000 anonymized support sessions against a single relay configuration so that provider latency would not blur the caching signal. Traffic ran through Fluxio, a streaming-first, pay-per-token relay where one key reaches models including Claude Haiku 4.5 and Gemini 2.5 Flash, and where replies arrive token by token over SSE. Because Fluxio speaks the OpenAI style API at api.fluxioapi.com, the same client code produced the streams for both models without rewriting our harness.

Each session ran four to six turns with warm traffic interleaved with cold traffic to simulate a busy support queue. We measured cache hit rate, time to first token, p95 end-to-end latency, and cost per resolved ticket for every strategy. The baseline was a naive build that resent the full context with no cache layer at all, and every strategy was judged against that baseline on identical transcripts.

  • – Cache hit rate measured at the request level rather than at the token level
  • – Time to first token sampled on every streamed response and reported as a median
  • – Cost per resolved ticket computed from metered input and output tokens
  • – Freshness checks comparing cached answers against a freshly generated control answer

§3 Verdict: Prefix Caching Won on Warm Repeats and Cold Starts Stayed Cheap

The clear winner was prefix caching on a stable, ordered context: system prompt first, policy block second, retrieval chunks third, session turns last. Warm hits dropped median time to first token by 41 percent and cut input-token spend on repeated turns by 34 percent. On Claude Haiku 4.5 the effect was more pronounced than on Gemini 2.5 Flash because the repeated prefix was larger relative to the turn content, but both models showed the same shape of improvement.

Exact-match response caching placed second, and only for a narrow slice of traffic. Greetings, password reset instructions, and store-hours answers are safe to serve from cache and accounted for about 11 percent of our volume. Beyond that slice, exact matches produced brittle answers when any detail in the user message shifted, so we capped the strategy to a small allowlist of intents.

  • – Prefix caching with a frozen context order delivered the best warm-hit return on investment
  • – Exact-match response caching is profitable only on a curated allowlist of repetitive intents
  • – Session-level memory reuse removed roughly 2,000 resent tokens per multi-turn ticket
  • – Cold starts stayed predictable because the cache warmed during the nightly replay job

§4 Semantic Response Caching Failed on Policy-Heavy Support Answers

We wanted semantic caching to work because support traffic clusters tightly around a few hundred intents. It did not. Embedding similarity matched refund answers across different order ages, shipping regions, and subscription tiers, producing confident replies that violated the current policy. Freshness checks caught 2.3 percent of cached answers drifting from the control answer, and that error rate is unacceptable in a support bot where a wrong refund promise becomes a real ticket.

The verdict is to keep semantic matching for retrieval, not for answer reuse. Use embeddings to find the right document chunks, then cache the assembled context prefix rather than the final reply. Version every policy block in the cache key so that an updated refund rule invalidates the affected prefixes immediately instead of waiting for a long time-to-live to expire. If you do cache generated text, attach a short time-to-live and route any answer containing money, dates, or account state through a verification step before it reaches the user.

  • – Versioned cache keys tied to the policy document revision number and effective date
  • – Short time-to-live values on any cache entry containing pricing or refund language
  • – Retrieval-only semantic matching that feeds a cached prefix instead of a cached reply

§5 Streaming Rules for SSE Caches, First Tokens and Live Replies

Streaming adds constraints that batch workloads never see. A cache hit that arrives after the first token has been sent is worthless to the user, so warming must happen before the request is accepted. We kept a warm pool of the top 50 context prefixes refreshed on deploy and evicted only entries with no hits for 24 hours, which kept the warm hit rate above 80 percent during business hours.

The relay layer mattered here as much as the cache design. Fluxio streams token by token with minimal first-byte overhead, so the latency we measured was dominated by cache hits and misses rather than by transport. Its pay-per-token pricing also meant cache savings showed up directly on the bill, and the same key reached Claude Haiku 4.5 and Gemini 2.5 Flash for side-by-side checks without changing client code.

  • – Warming the top context prefixes on deploy so the first live token is never delayed
  • – Keeping cache keys ordered from the most stable block to the most volatile block
  • – Evicting cache entries after 24 hours without a hit to protect memory during traffic spikes
  • – Measuring time to first token per cache state, because averages hide cold-start regressions

Field-tested verdict: freeze a stable context order, cache the prefix aggressively, keep exact-match responses on a small allowlist, and never reuse generated answers across policy versions. Sign up for Fluxio and stream your first cached support reply today.

Create a Fluxio account →

More from the current