AI latency and caching: faster responses without losing freshness or access control

Caching can reduce AI response time and expenditure, but a result generated for one person may be inappropriate for another. In systems using company knowledge, the cache key becomes part of the security boundary. Performance optimisation must preserve data meaning, source versions and current access rights.

Measure the critical path

Break completion time into queue waiting, retrieval, source loading, model execution and result validation. Time to first token does not describe task completion when the user still waits for validation or a CRM update. Measure the long tail separately for document sizes and case classes.

Do not optimise every stage without identifying the constraint. If approval dominates elapsed time, a faster model may barely change the user's experience. If repeated loading of the same approved material dominates, context caching may be more valuable than changing providers.

Choose the caching layer deliberately

You can cache source documents, search results, prepared context or final answers. Each has different invalidation costs. An answer depends on more inputs than one source document, so it needs a more complete dependency record and a more cautious reuse policy.

A key should include the organisation boundary, effective permission scope, data version, retrieval configuration and relevant instruction version. Question text alone is usually insufficient. Two employees can ask the same question about contract terms while having access to different customers and documents.

Freshness belongs to the business process

Consider an illustrative purchasing-policy assistant. After an approval limit changes, an old answer can remain convincing. A TTL should reflect business tolerance, but it does not replace invalidation after a material source change. Revoked access and document deletion require especially explicit handling.

Record which sources an answer depends on. This enables selective invalidation rather than flushing everything. When freshness or permission cannot be established, recomputing or abstaining is safer than serving information that may no longer be authorised.

Layer-specific decisions

LayerPrincipal risk
DocumentReusing a deleted or superseded version
Search resultStale access filtering or ranking
Model contextHidden dependencies on multiple sources
AnswerReuse under the wrong person's context

A stale-on-error policy needs separate approval. It may be reasonable for a stable general instruction but unacceptable for prices, access decisions or transaction status. It should not be a product-wide convenience switch.

Define what constitutes equivalent permission scope rather than simply attaching a user identifier to every key. Per-user isolation is straightforward but can sharply reduce reuse. Shared entries require evidence that every recipient is entitled to the same sources, including after access changes.

Prevent refresh stampedes

When a popular entry expires, concurrent requests may all start expensive refresh work. Use single-flight refresh, bounded concurrency and staggered refresh scheduling. Waiting users need an understandable state instead of competing model executions that inflate cost and increase tail latency.

Test after role changes, source edits, document deletion and prompt releases. Measure hit rate alongside incorrectly reused results. A high hit rate is not a success if it comes from serving answers whose authority or freshness has expired.

Include a cache-bypass path in diagnostics so operators can compare cached and recomputed outcomes. Restrict that capability appropriately: unrestricted bypass can itself become an expensive public endpoint.

Exercise access-revocation races

In an illustrative case, an employee starts a request and then loses access to one source. Previously retrieved material may remain in context or cache. Define when permission to release the answer is checked and how in-flight work behaves. Updating the search index alone may not close the gap.

Also reverse the completion order of two refreshes using different document versions. An older refresh must not overwrite a newer valid result. Check dependency versions when publishing cache entries. Acceptance evidence should include controlled refusal when freshness or access cannot be established, not only fast successful responses.

Benchmark cold start, normal hits and refresh after source changes separately. A warm-cache demonstration may not represent morning demand after a deployment or node loss. Also test workloads with little repetition, where permission isolation limits reuse.

Include cache storage and invalidation effort in the cost comparison. If most entries are never reused, the mechanism may add complexity without material benefit. Approval should reflect the actual request distribution and the cost of preserving freshness and authorisation, rather than an unusually favourable repeated-question benchmark.

Optimise performance with Geekforce

We improve AI system latency and costs while preserving data boundaries. Together, we can find the actual source of delay and design a caching policy appropriate to your workflow.

Sources and further reading

Don't just take our word for it — read what our clients say on independent platforms.