Skip to content

How should my app prevent a CDN from caching private generated results?

Return an explicit private caching policy from your application's authenticated result routes, and verify the CDN or reverse proxy honors it. AISwapLab's private content route uses private, no-store, but a proxy that constructs a new response can accidentally drop those protections or apply an unsafe shared-cache rule.

PROTECT API ACCESS AND RESULTSAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Identify private response routes; Set policy at the final boundary; Test across two sessions.
Workflow diagram: Identify private response routes → Set policy at the final boundary → Test across two sessions. Read the article for evidence and limits.

Privacy can be lost at the proxy

Authentication on the origin does not automatically make every intermediary cache safe. A route-level CDN rule can cache a private response under a URL shared by several users. Review the actual deployed response and cache behavior, not only backend source code.

What to do next

  1. 01

    Identify private response routes

    List media, chat JSON, thumbnails and task-specific metadata that your application serves after authorization. Keep their caching policy separate from public documentation and static assets, which can use different performance strategies.

  2. 02

    Set policy at the final boundary

    Apply the reviewed private no-store headers where the response leaves your application, including error and partial-content paths where appropriate. Inspect CDN rules for overrides, forced caching or cache keys that ignore user-specific context.

  3. 03

    Test across two sessions

    Fetch a synthetic private asset as one authorized test user, then request the same route as another user or without a session. Confirm no cached body bypasses the application's authorization decision and inspect cache-status diagnostics.

A concrete example

Illustrative example: a backend proxy downloads a private image and returns a new response. Its final response explicitly remains private and non-storable, and a second session cannot receive the first session's bytes from an edge cache.

Before you call it ready

  • Final responses retain the private policy.
  • CDN overrides are reviewed.
  • Cross-session cache tests use synthetic assets.

When to stop or choose another method

Stop enabling shared caching for authenticated result routes until cache keys, authorization and intermediary behavior have been verified together.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation