CacheCore
Response Headers
CacheCore

Response Headers

Every request to and response from the Cachecore gateway uses HTTP headers for authentication, dependency tagging, and cache diagnostics.

Request headers (you send these)

HeaderRequiredDescription
AuthorizationYes*Bearer cc_live_xxxxx.eyJ... Preferred auth method
X-Cachecore-TokenYes*Alternative auth header (backward compatibility)
X-Cachecore-DepsNoBase64url-encoded JSON array of dependency declarations

*One of Authorization or X-Cachecore-Token is required. Authorization: Bearer is preferred.

Bypass mode: To skip caching entirely for a request, omit the auth token. The gateway treats a missing token as bypass mode, routing the request directly to OpenAI without cache lookup or write. When using the Python client, request_context(bypass=True) handles this automatically.

Response headers (Cachecore returns these)

HeaderValuesDescription
X-CacheHIT_L1, HIT_L1_STALE, HIT_L2, MISS, BYPASSCache result for this request
X-Cache-Similarity0.001.00Cosine similarity score (L2 hits); 1.00 for L1, 0.00 for MISS/BYPASS
X-Cache-Ageinteger (seconds)Age of the cached entry; 0 for MISS/BYPASS

Reading X-Cache

The X-Cache header encodes both the cache result and the tier in a single value:

ValueLatencyDescription
HIT_L1~5msExact hash match. Response served from Redis L1
HIT_L1_STALE~5msStale L1 match. Served from cache; background refresh triggered
HIT_L2~15msSemantic match. Response served from Redis L2 HNSW index
MISS1-3sNo match. Request forwarded to OpenAI, response cached
BYPASS1-3sNo auth token. Request forwarded to OpenAI, response not cached

Dependency declaration format

The X-Cachecore-Deps header is a base64url-encoded JSON array:

[
  {"dep_id": "doc:contract-123", "expected_hash": "v1"},
  {"dep_id": "table:products", "expected_hash": "2024-01-15"}
]

dep_id is an arbitrary string identifying a data resource. Convention: <type>:<identifier>.

expected_hash is the data version at cache-write time. If the dependency's current hash has been updated via /v1/invalidate, cached entries tagged with it are rejected on lookup.

Debug headers

When debug mode is enabled on your project, an additional header is returned:

HeaderDescription
X-Cachecore-Namespace-HintFirst 12 hex characters of the namespace hash

Useful for verifying that two requests derive the same namespace across environments.