Guide

How to test cache isolation across SaaS accounts

The PainHunt Team· Published · 5 min read

TL;DR: Warm a response under one identity, switch to another and inspect the returned data, current permission decision and each cache layer. Repeat after a role or access change. Test with synthetic, owned accounts; a cache hit is an optimization outcome, not authorization evidence.

Start with the representation's real scope

Two people can request the same URL while being entitled to different data. A report may vary by account, object, role, plan, locale, filters or another declared input. Some public aggregate responses may be reusable broadly. An account's private report usually is not.

Write down which inputs change the representation and which inputs change permission to receive it. Those are related questions, but they are not identical. A key that separates two accounts can still serve a formerly authorized user after access was removed if the application skips its current permission check.

Use an owned fixture with clearly different permitted values, such as account A's marker alpha and account B's marker bravo. Do not use real customer records to see whether an isolation failure occurs.

Inventory the layers before clearing anything

List where a response or derived value can persist: a shared HTTP cache, a server process, an optional remote cache, a client query store or browser navigation state. Record the lifetime and scope you expect at each layer.

RFC 9111 defines HTTP cache behavior, including private and shared caches. Its directives do not automatically govern an application-owned map that stores a final result. Check that layer's lookup and authorization logic separately.

Begin with the application in its ordinary state. If the first action is clearing every cache, a test may only exercise cold generation. The failure can appear on the second request, after an allowed representation is already stored.

Use isolated test environments and an approved cleanup procedure. Do not purge a shared production cache or alter real permissions merely to obtain a screenshot.

A toy fixture shows why URL-only reuse is unsafe

We ran a synthetic, in-memory fixture with two authorized accounts and one path, /report. The first version stored the response under the path alone. Account A warmed it; account B then received the stored owner marker for A.

In a second version, the lookup used account plus path, and a current permission check ran before reuse. A received A's marker, B received B's marker, and removing A's permission produced a denied result even though A's old entry remained in the map.

This is a deliberately small demonstration of key and permission boundaries. It is not a test of a real browser, CDN, framework or SaaS product. It does not establish that account plus path contains every input your application needs.

Use that distinction when designing your own test: an expected key is a hypothesis to verify against the actual representation, not a universal recipe copied from a toy map.

Run the warm-and-switch matrix

Keep one request shape constant while changing a declared dimension. Capture the current identity, authorized resource, response marker, cache outcome and relevant request or response policy.

Sequence Required observation
A warms, then B reads B receives only B's permitted representation
B warms, then A reads The reverse order also respects scope
Allowed role changes Newly restricted fields do not survive through reuse
Access is removed Current permission prevents reuse of an old allowed result
Same account changes filters The response matches the new declared inputs
A request fails Failure does not become a successful empty result in the cache

Choose the actual roles and transitions the product supports. A guest-to-paid switch does not substitute for two distinct paid accounts. Conversely, a truly public representation does not need a fabricated per-user partition merely because another endpoint is private.

Check both result contents and metadata. Correct rows with a stale plan label, pagination total or permission flag can still mislead the interface.

Read HTTP cache policy precisely

MDN's Cache-Control reference distinguishes revalidation from preventing storage. no-cache can permit storage with validation before reuse; no-store addresses storage. private limits shared-cache storage but does not, by itself, prevent a private browser cache.

Apply the actual policy your endpoint needs and inspect what the deployed response sends. Do not infer it from a comment in source code. Authentication-related requests have additional HTTP caching rules and exceptions; do not assume that carrying a cookie makes every response uncacheable.

A new response policy also does not reach backward in time and prove old entries are gone. Include the supported treatment of previously stored data in a change plan. Test the deployed behavior without treating one cache header as a complete confidentiality control.

Include the browser's account transition

Use two permitted test identities and inspect sign-out, sign-in and navigation under the actual client. A server can return the correct response while an old client store continues displaying a previous account's data.

Record whether client keys include the needed scope, when cached views are invalidated and how an unfinished request from the old account is handled. A late response should not overwrite the new account's current view.

Do not equate a back-navigation snapshot with a newly fetched response. Distinguish historical UI restoration, client-cache reuse and a network request when recording the result. Logs and headers alone may miss what the reader actually sees.

Preserve an actionable test record

Keep the tested version, controlled identities, transitions, expected fields and actual observations together. Re-run the relevant transitions after a cache or authorization change, rather than assuming a cold successful request covers them.

The caller-identity guide tests how a tool receives a trusted principal and applies object access. Cache isolation adds a temporal question: can a result from an earlier principal or permission state be reused now?

If the problem is a plan entitlement rather than account data, use the free-and-paid entitlement note to define the expected behavior. The validation brief can record the bounded outcome. Neither a passing fixture nor a model-generated research score proves every production account is isolated.

Frequently asked questions

Does Cache-Control private isolate every application cache?

No. It controls storage by shared HTTP caches under the HTTP caching rules. Your application memory, database cache, client query store and other state need their own scope and authorization behavior. A response header does not implement a key for an in-process map.

Is a subscription tier always a sufficient cache key?

Only when the cached representation is genuinely reusable across everyone in that tier and current authorization is still enforced. Account-private records require the relevant account or resource scope. Equal price plans do not make two customers' data interchangeable.

What should I inspect after removing access?

Warm the relevant caches before removing access in a controlled fixture, then request the resource again. The current permission decision must govern reuse. Also inspect browser navigation and client state so a previous allowed response is not presented as a newly authorized result.

Research the problem behind your idea

Explore problem summaries and source links to compare workflows and decide what to investigate next.

Open the Pain Point Browser

Related articles