Skip to main content

Response Cache page

The Response Cache page shows how much traffic the gateway answers from its own response cache, runs a live health check against the cache, and lets a proxy admin configure the Redis connection behind the response cache and the separate coordination Redis that proxy pods share. Open it at /ui/caching. It sits under Developer Tools in the left nav as Response Cache.

The nav item is shown to the session roles Admin (proxy admins) and Admin Viewer (proxy admin viewers). Org admins, internal users and internal viewers do not see it. The page itself has no extra guard, so the backend decides what a direct visit can load. The cache health check, Redis info and the cache settings routes accept only proxy admins and, for reads, Admin Viewers. Key delete and flush accept proxy admins only. No license feature is needed for this page.

The page has five tabs, Cache Analytics, Cache Health, Cache Management, Cache Settings and Coordination Redis. To the right of the tabs the page shows Last Refreshed with the time the analytics were last loaded, and a Refresh button that reloads the analytics and updates that time.

This page covers the gateway's response cache only, meaning requests answered from cache without calling the model provider. Provider side prompt caching (cached input tokens reported by Anthropic, OpenAI and other providers) is not shown here. The Analytics tab says so and points to Prompt Caching Metrics on the Usage page and to individual requests on the Logs page.

Requests under a zero data retention policy never read from or write to the response cache, so they always count as API requests here. See What Spanway stores for the full retention rules.

What this page is for​

The response cache answers repeated prompts from Redis instead of the provider, which saves money and time. This page shows how much of your traffic that is, lets you check that the cache really works, and holds the Redis connection for the cache and for the coordination Redis the replicas share, so an admin never has to edit a config file or restart the gateway to change them.

A real-world scenario​

A product FAQ bot gets the same twenty questions hundreds of times a day. The admin sets up a Redis response cache with a ten minute lifetime on this page, confirms the connection with Test Connection and the running cache with Run Health Check, and watches the Cache Hit Ratio climb past 60 percent for the bot's key on the Cache Analytics tab. When the FAQ changes, the admin flushes the cache from the API so nobody gets a stale answer.

Step by step​

  1. Open /ui/caching as a proxy admin and pick the Cache Settings tab.
  2. Choose Node (Single Instance) under Redis Type, fill in Host, Port and Password or a Redis URL, and set Namespace and TTL (seconds) under Advanced Settings.
  3. Click Test Connection and wait for Cache connection test successful!, then click Save Changes. The toast reads Cache settings updated successfully.
  4. Pick the Cache Health tab and click Run Health Check. Cache Status shows a green check and Cache Configuration reads redis.
  5. Send the same request twice from an application, then pick the Cache Analytics tab and select the key under Select Virtual Keys. Cache Hits reads 1 and the chart shows the hit under the call type.

The same steps over the API:

curl -X POST http://localhost:4000/cache/settings/test \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"cache_settings": {"type": "redis", "host": "redis.internal", "port": "6379", "password": "***REDACTED***"}}'

curl -X POST http://localhost:4000/cache/settings \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"cache_settings": {"type": "redis", "host": "redis.internal", "port": "6379", "password": "s3cret", "namespace": "prod", "ttl": 600}}'

curl http://localhost:4000/cache/ping -H "Authorization: Bearer $SPANWAY_MASTER_KEY"

Expected result​

The test answers {"status": "success", "message": "Redis connection test successful", "error": null}, the save answers {"message": "Cache settings updated successfully", "status": "success", "settings": {...}} with the password redacted, and the ping answers "status": "healthy" with "ping_response": true and "set_cache_response": "success". The gateway caches on the new Redis from the next request, without a restart, and the save is recorded in the audit log.

Cache Analytics tab​

This tab is open by default. It reads aggregated spend logs for the chosen date range and groups them by call type (the endpoint the request went to). Proxy admins and Admin Viewers see the whole proxy. The gateway scopes the same data to the caller's own requests for every other role, so a user who reaches it directly never sees other users' key aliases, models or counts.

ControlTypeWhat it does
Select Virtual KeysMulti selectLimits the numbers to requests made with the chosen key aliases. The options come from the key aliases found in the selected range. If none match your search it shows No virtual keys found.
Select ModelsMulti selectLimits the numbers to the chosen models. The options come from the models found in the selected range. If none match it shows No models found.
Date range pickerDate rangeSets the range. It defaults to the last 7 days ending now, and offers presets such as Today, Last 7 days, Last 30 days, Month to date and Year to date. Only the date part is sent, so the range covers whole days.

Changing any filter reloads the data.

Three stat cards sit under the filters.

CardMeaning
Cache Hit RatioThe share of requests answered from the response cache, shown as a percentage with two decimals. It shows 0% when the range has no requests.
Cache HitsThe number of requests answered from cache, in compact form (for example 1.2K).
Cached Completion TokensThe completion tokens served from cache instead of being generated by a provider.

Cache Hits vs API Requests chart​

A stacked bar chart with one bar per call type. Each bar has three segments.

SeriesMeaning
LLM API requestsRequests that reached a model provider and succeeded.
Cache hitRequests answered from the response cache.
Failed requestsRequests that failed.

Click a red Failed requests segment to open the error breakdown for that call type, described below. When the data has a call type named Unknown, the chart adds a note that Unknown groups spend logs that recorded no endpoint. Older proxy versions wrote those for requests rejected before routing, so they are not necessarily LLM API requests.

Failed requests by error code card​

This card opens under the first chart when you click a failed segment, with the title Failed requests by error code followed by the call type. It shows one bar per error code, sorted from most to least failures. Hover a bar to see the error classes behind that code and how many failures each class had. The close button (labelled Close error breakdown for screen readers) hides the card. The card also closes by itself when a filter change leaves that call type with no failed requests.

Cached Completion Tokens vs Generated Completion Tokens chart​

A stacked bar chart with one bar per call type that compares Generated Completion Tokens (produced by a provider) with Cached Completion Tokens (served from cache).

Cache Health tab​

This tab runs a live check against the cache the gateway is using right now.

ControlTypeWhat it does
Run Health CheckButtonCalls the cache ping route. For a Redis cache the gateway pings Redis and writes a test entry. While it runs the button reads Running Health Check... and is disabled. When it finishes, the time the check took is shown next to the button in milliseconds.

The result appears in a panel with two tabs.

Summary shows Cache Status with a green check when the status is healthy and a red cross otherwise. When the check failed it adds an Error Details group with Error Message and Traceback. It always shows a Cache Details group with Cache Configuration (the cache type), Ping Response, Set Cache Response and spanway_settings.cache_params. When the cache type is redis it adds a Redis Details group with Redis Host, Redis Port, Redis Version, Startup Nodes and Namespace. Fields that have no value show N/A.

Each row shows the first 50 characters of its value. Click the expand arrow on a row to see the full value, and hover a row to reveal a copy button that copies the full value to the clipboard.

Raw Response shows the whole response as formatted JSON. The gateway masks sensitive values such as passwords in the cache parameters before it sends them, so the raw view does not contain the Redis password.

Cache Management tab​

This tab is for clearing out cached answers, for example after a provider fixed a bad model version and you do not want the gateway to keep replaying the old responses. It also shows what the Redis server behind the cache is doing. Every action works on a redis response cache only.

Scenario: a support team notices that one prompt keeps getting the same outdated answer. A proxy admin copies the x-spanway-cache-key header from that response, deletes the key here, and the next request goes to the provider again.

CardControlWho can use itWhat it does
Redis InfoLoad Redis Info (then Reload Redis Info)Proxy admins and proxy admin viewersCalls GET /cache/redis/info and shows the Redis version, mode, uptime, connected clients, used and max memory, keyspace hits and misses, evicted keys and commands processed, plus a Raw Redis info section with the whole answer. Clients seen by the gateway reads "Not available on this Redis instance" when a managed Redis refuses the client list.
Delete Cache KeysCache keys text box and Delete KeysProxy adminsDeletes the listed keys through POST /cache/delete. Enter one key per line or separate them with commas. Duplicates and blank lines are dropped. On success it shows "Deleted 2 cache keys" and clears the box, and on failure it keeps the keys so you can retry.
Flush CacheFlush All Cache EntriesProxy adminsOpens Flush the whole cache?, which says "Cached responses are deleted and the next requests are sent to the providers at full cost. Cached key lookups are cleared too and read again from the database. Responses saved under a per-request namespace stay until deleted by key. Rate limits, budgets and other data on the same Redis are not touched." Flush Cache calls POST /cache/flushall and shows "Cache flushed". Cancel keeps the cache. This cannot be undone.

Flush All Cache Entries removes more than one answer, so here is exactly what it deletes. It removes only the keys that are cached responses, meaning a SHA-256 cache key on its own or behind the cache namespace. Rate limit and spend counters, pod locks and any other data on the same Redis stay in place, which matters when the coordination Redis is Borrowed from response cache (see the Coordination Redis tab below). Cached key lookups stored on the same Redis are cleared too, and the gateway reads them again from the database on the next request. Entries saved under a per-request namespace ("cache": {"namespace": "..."}) are kept, so delete those by key. The answer reports how many entries were removed, for example {"status": "success", "deleted_entries": 1284}.

Key delete and flush each write an audit row on Spanway_CacheConfig with object_id response_cache, so you can see who emptied the cache and when. The delete row holds the number of keys and the SHA-256 of each one, never the keys, and the flush row holds the number of entries removed. See audit logs.

Internal users, internal viewers and org admins see the note "Only proxy admins and proxy admin viewers can open the cache tools." instead of the cards, because the gateway refuses them on all three routes.

Steps to delete one cached answer:

  1. Open /ui/caching as a proxy admin and click the Cache Management tab.
  2. Paste the value of the x-spanway-cache-key response header into Cache keys.
  3. Click Delete Keys.

Expected result: "Deleted 1 cache key" appears, and the next identical request is answered by the provider and cached again. Each gateway worker also keeps a short-lived in-memory copy of the entries it served, so a worker that served the entry moments ago can keep answering from that copy until the entry's TTL lapses. Use a short TTL when entries must disappear at once, or restart the workers. POST /cache/delete answers {"status": "success"} and POST /cache/flushall answers {"status": "success", "deleted_entries": <count>}.

The same actions from the command line, with an admin key in SPANWAY_API_KEY:

curl -sS "http://localhost:4000/cache/redis/info" -H "Authorization: Bearer $SPANWAY_API_KEY"

curl -sS -X POST "http://localhost:4000/cache/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
-d '{"keys": ["spanway:chatcmpl-abc123"]}'

curl -sS -X POST "http://localhost:4000/cache/flushall" -H "Authorization: Bearer $SPANWAY_API_KEY"

Errors you may see:

StatusMessageMeaning and fix
401Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/cache/flushall. Your role=internal_user. ...An internal user, internal viewer or org admin key or session called a cache route. Sign in as a proxy admin, or as an Admin Viewer for Redis info and the health check.
401Authentication Error, No api key passed in.The request carried no key. Send Authorization: Bearer <key>.
403user not allowed to access this route, role= proxy_admin_viewer. Trying to access: /cache/flushallAn Admin Viewer tried key delete or flush. Admin Viewers can only read, so ask a proxy admin.
422Field required or Tuple should have at least 1 item after validation, not 0 at body.keysPOST /cache/delete was sent without a keys list or with an empty one. Send at least one key.
503Cache not initialized. spanway.cache is NoneNo response cache is configured. Set one up in the Cache Settings tab or the config file.
400Cache type local does not support deleting a key, Cache type local does not support flushing or Cache type local does not support redis infoThe cache is not Redis. Key delete, flush and Redis info need type: redis.
500Cache Delete Failed(...)Redis refused the key delete. Check the connection on the Cache Health tab.
503Service Unhealthy (...)Redis could not be reached for Redis info or flush. Check the connection on the Cache Health tab.

Cache Settings tab​

This tab configures the Redis connection for the response cache. When it opens it loads the saved settings, fills the form with them and picks the matching Redis Type. Saved secrets are never loaded into the form. A secret field that already has a value shows the placeholder Already set. Enter a new value to replace it. Leave it empty to keep the saved secret.

Redis Type​

OptionMeaning
Node (Single Instance)A standard single Redis node. This is the default.
ClusterRedis Cluster mode for high availability and horizontal scaling.
SentinelRedis Sentinel mode for high availability with automatic failover.
SemanticSemantic caching that reuses responses for similar prompts.

The description under the selector changes with the type. The type decides which sections appear below.

Connection Settings​

FieldTypeWhat it does
Redis URLPasswordA full Redis or Valkey connection URL, for example redis://:password@host:6379/1. The field hides what you type, with a show and hide button, because the URL can hold the password. When set it takes precedence over Host, Port, Password and Database Index. It is treated as a secret, so it is never prefilled.
HostTextRedis server hostname or IP address.
PortTextRedis server port. It defaults to 6379. It must be a whole number from 1 to 65535.
Database IndexNumberThe logical database index that isolates the cache, for example 1 for redis://host:6379/1. It must be a whole number of 0 or more.
PasswordPasswordRedis server password. It is a secret and is never prefilled.
UsernameTextRedis server username, if your server needs one.

Cluster Configuration​

Shown only for Cluster.

FieldTypeWhat it does
Startup NodesText areaThe cluster startup nodes as a JSON array, for example [{"host": "127.0.0.1", "port": "7001"}]. It must be valid JSON that uses double quotes, and it must be an array.

Sentinel Configuration​

Shown only for Sentinel.

FieldTypeWhat it does
Sentinel NodesText areaThe Sentinel nodes as a JSON array, for example [["localhost", 26379]]. It must be a valid JSON array.
Service NameTextThe master service name for Redis Sentinel.
Sentinel PasswordPasswordPassword for Sentinel authentication. It is a secret and is never prefilled.

Semantic Configuration​

Shown only for Semantic.

FieldTypeWhat it does
Similarity ThresholdNumberHow similar a prompt must be to reuse a cached response. It defaults to 0.8 and must be a number.
Embedding ModelSearchable selectThe embedding model used to compare prompts. The list shows the model groups on the proxy whose mode is embedding. If none match it shows No models found.
Semantic Cache ScopeSelectWho can share a semantic cache hit. Key (shared by all end users of the key/team/org) is the default. End user (isolated per end user) keeps hits separate per end user, and requests without an end user fall back to the key scope.

Advanced Settings​

A collapsed section. Its fields are validated only while it is open.

SectionFieldTypeWhat it does
SSL SettingsSSLSwitchTurns on an SSL or TLS connection. Off by default.
SSL SettingsSSL Cert ReqsTextCertificate requirements, one of None, CERT_REQUIRED or CERT_OPTIONAL.
SSL SettingsSSL Check HostnameSwitchTurns on hostname verification. Off by default.
Cache ManagementNamespaceTextA prefix added to every cache key.
Cache ManagementTTL (seconds)NumberHow long cached items live, in seconds. It must be a number.
Cache ManagementMax ConnectionsNumberThe largest number of connections in the pool. It must be a whole number of 0 or more.
GCP AuthenticationGCP Service AccountTextThe GCP service account used for IAM authentication, for example projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com.
GCP AuthenticationGCP SSL CA CertsTextPath to the SSL CA certificate file for GCP Memorystore Redis.

Buttons​

ButtonWhat it does
Test ConnectionValidates the form, then asks the gateway to connect with the values on screen without saving them. It reads Testing... while it runs. A success shows Cache connection test successful! and a failure shows Connection test failed with the reason.
Save ChangesValidates the form, saves the settings and makes the gateway start using the new cache right away. It reads Saving... while it runs. A success shows Cache settings updated successfully and reloads the form. Empty fields are left out of what is saved, and an untouched secret keeps its saved value.

| Turn Cache Off | Asks for confirmation, then removes the saved cache settings and stops answering requests from the cache on every gateway instance. Use it when cached answers are stale or wrong, or while you move to another Redis. Every request then goes to the model again, which is slower and costs more. Answers already stored in Redis stay until they expire, and a cache set in the config file comes back at the next restart. Save Changes turns the cache back on. A success shows Response cache turned off. Proxy admins only, and each use writes a deleted audit row. |

Validation errors appear under the field and stop both buttons until fixed. Saving replaces the previous response cache settings. There is no undo, so note the old values first if you may need them back.

Coordination Redis tab​

The coordination Redis is the Redis that proxy pods use to coordinate work, such as cross pod rate limits, spend tracking and the pod lock manager. It is configured separately from the response cache. A warning line on the tab says Saved changes take effect on proxy restart.

A badge next to the Coordination Redis heading shows where the current connection comes from, with an explanation line under it.

BadgeMeaning
Configured heregeneral_settings.coordination_redis is set, so coordination uses its own Redis connection.
Borrowed from response cacheNo coordination Redis is configured, so the proxy reuses the response cache's Redis connection.
From REDIS_ environment*No coordination Redis is configured, so the proxy falls back to the REDIS_* environment variables.
Not configuredCross pod rate limits, spend tracking and the pod lock manager have no Redis to coordinate through.

When a Redis is configured but the gateway cannot read or update a counter on it, requests that carry a rate limit or budget get a 503 by default instead of passing unchecked. Redis requirements explains this and the settings that turn it off.

Redis Type offers Node (Single Instance), Cluster and Sentinel. The type is picked from the saved values when the tab loads. Sentinel is chosen when Sentinel nodes are saved, Cluster when startup nodes are saved, and Node otherwise.

SectionFieldTypeWhat it does
Connection SettingsRedis URLPasswordA full Redis or Valkey URL. When set it takes precedence over Host, Port, Username and Password. It is a secret and is never prefilled.
Connection SettingsHostTextRedis server hostname or IP address.
Connection SettingsPortNumberRedis server port. It defaults to 6379 and must be a whole number from 1 to 65535.
Connection SettingsUsernameTextRedis server username, if needed.
Connection SettingsPasswordPasswordRedis server password. It is a secret and is never prefilled.
Cluster ConfigurationStartup NodesText areaShown for Cluster. A JSON array such as [{"host": "127.0.0.1", "port": 7001}].
Sentinel ConfigurationSentinel NodesText areaShown for Sentinel. A JSON array such as [["localhost", 26379]].
Sentinel ConfigurationService NameTextShown for Sentinel. The master service name.
Sentinel ConfigurationSentinel PasswordPasswordShown for Sentinel. It is a secret and is never prefilled.
SSL SettingsSSLSwitchTurns on an SSL or TLS connection. Off by default.

Secret fields that already have a value show Already set. Enter a new value to replace it. Leave them empty to keep the saved value.

ButtonWhat it does
Test ConnectionValidates the form and pings a temporary client built from the values on screen, without saving or touching the running proxy. A healthy result shows Coordination Redis connection test successful! and anything else shows Connection test failed with the error.
Save ChangesValidates the form and saves the settings under general_settings.coordination_redis. A success shows Coordination Redis settings saved. Restart the proxy to apply them. The running pods keep their current connection until they restart.

Empty, error and disabled states​

When the selected range has no traffic, the stat cards show 0% and 0 and the charts are empty. Widen the date range or clear the key and model filters. If the proxy has no database connected, the analytics request fails and nothing loads.

When no response cache is set up, Run Health Check returns an unhealthy result whose error message says the cache is not initialized. Configure the cache in the Cache Settings tab or in the config file, then run the check again.

If the cache settings cannot be loaded, the page shows Failed to load cache settings and the form stays empty. If saving fails it shows Failed to update cache settings. Saving needs a connected database and STORE_MODEL_IN_DB set to True on the proxy, and the gateway refuses the save otherwise. If the coordination settings cannot be loaded, the page shows Failed to load coordination Redis settings, and a failed save shows Failed to update coordination Redis settings.

Buttons are disabled only while their own request runs. Field errors appear under each field and block Test Connection and Save Changes until fixed.

Errors​

What you seeWhyFix
Connection test failed with Connection refusedThe host or port is wrong, or a firewall blocks the gateway host.Check the address from the gateway, not from your laptop.
Connection test failed with AUTH or WRONGPASSThe password is wrong, or nothing is saved yet and the field was left empty.Type the password.
Connection test failed with a certificate messageThe server requires TLS.Turn on SSL under Advanced Settings and set SSL Cert Reqs to match the server.
Only Redis cache type is currently supported for testingTest Connection only tests Redis types.Save and use Run Health Check instead.
Failed to update cache settingsThe gateway has no database or STORE_MODEL_IN_DB is not True.Connect a database, set the variable and restart.
Cache Status with a red cross and Cache not initializedNo response cache is configured.Save settings on the Cache Settings tab or set cache: true in the config file.
No cache settings are saved, so there is nothing to turn off. after Turn OffNothing was saved on this tab, so the cache, if any, comes from the config file.Remove cache from the config file and restart the gateway.
Failed to load coordination Redis settingsThe settings row could not be read.Check the gateway log.
The Coordination Redis badge does not change after savingCoordination settings apply at the next restart.Restart the replicas.

Differences by role and license​

RoleWhat changes
Admin (proxy admin)Sees the page and can use every tab and button, including key delete and flush on Cache Management.
Admin ViewerSees the page, the analytics and the saved settings, and can run the health check and Load Redis Info. The delete and flush cards are hidden. The Test Connection and Save Changes buttons still appear, but the gateway rejects those requests for a view only admin, so they end in an error message.
Org admin, internal user, internal viewerThe nav item is hidden. If they open the URL directly, the gateway rejects the health check and the settings requests.

The page needs no license feature.

Caching on the gateway explains how response caching works and how to control it per request. Cache backends lists the supported backends and their options. Redis requirements covers which features need Redis, including the coordination Redis, and how to connect standalone, cluster and Sentinel deployments. Prompt caching covers provider side prompt caching, which this page does not show.