Update Cache Settings

Overview

Updates cache settings for an API proxy. Cache settings control how API responses are cached and retrieved.

Endpoint

PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/cache/

Authentication

Requires a Personal API Access Token.

Authorization: Bearer YOUR_TOKEN

Request

Headers

Header Value Required
Authorization Bearer {token} Yes
Content-Type application/json Yes

Path Parameters

Parameter Type Required Description
projectName string Yes Project name
apiProxyName string Yes API Proxy name

Request Body

Full JSON Body Example

{
  "name": "Cache Settings",
  "description": "Cache configuration",
  "cacheActive": true,
  "cacheOnlyHttpGetRequests": true,
  "cacheKeyType": "QUERY_PARAMS",
  "cacheStorageType": "LOCAL",
  "capacity": 1000,
  "ttl": 3600,
  "handlingAction": "CONTINUE",
  "invalidationRequiresAuthn": false,
  "cacheNullValue": false,
  "variableList": []
}

Request Body Fields

Field Type Required Default Description
name string Yes - Cache settings name
description string No - Cache settings description
cacheActive boolean No false Enable/disable cache
cacheOnlyHttpGetRequests boolean No true Cache only GET requests (if false, caches all methods)
cacheKeyType string No QUERY_PARAMS Cache key type
cacheStorageType string No DISTRIBUTED Cache storage type
capacity integer No - Maximum cache capacity (number of entries)
ttl integer No - Time to live in seconds
handlingAction string Yes - Cache handling action when cache hit occurs
invalidationRequiresAuthn boolean No false Require authentication for cache invalidation
cacheNullValue boolean No false Cache null/empty responses
variableList array No [] List of variables for custom cache key (if cacheKeyType=CUSTOM)

EnumCacheKeyType

  • QUERY_PARAMS - Use query parameters as cache key
  • CUSTOM - Use custom variables as cache key (requires variableList)

EnumCacheStorageType

  • LOCAL - Local cache (per worker instance)
  • DISTRIBUTED - Distributed cache (shared across all workers)

EnumCacheHandlingAction

  • CONTINUE - Return cached response and continue to backend (for logging/monitoring)
  • STOP - Return cached response and stop (do not call backend)

Variable Object (for variableList when cacheKeyType=CUSTOM)

{
  "name": "userId",
  "type": "HEADER",
  "dataType": "STRING"
}

EnumVariableType

  • HEADER - Extract from HTTP header
  • PARAMETER - Extract from query parameter
  • BODY - Extract from request body
  • CONTEXT_VALUES - Extract from context values
  • CUSTOM - Custom variable

EnumConditionVariableDataType

  • NUMERIC - Numeric value
  • STRING - String value
  • DATE - Date value

Response

Success Response (200 OK)

{
  "success": true
}

Response Fields

Field Type Description
success boolean Indicates if the request was successful

Error Response (400 Bad Request)

{
  "error": "bad_request",
  "error_description": "handlingAction is required"
}

Common Causes

  • Missing required field handlingAction
  • Invalid enum values
  • Invalid cache configuration

Error Response (401 Unauthorized)

{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}

Error Response (404 Not Found)

{
  "error": "not_found",
  "error_description": "ApiProxy (name: MyAPI) was not found!"
}

cURL Example

Example 1: Basic Cache Configuration

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/cache/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Cache Settings",
    "cacheActive": true,
    "cacheOnlyHttpGetRequests": true,
    "cacheKeyType": "QUERY_PARAMS",
    "cacheStorageType": "LOCAL",
    "capacity": 1000,
    "ttl": 3600,
    "handlingAction": "STOP",
    "cacheNullValue": false
  }'

Example 2: Custom Cache Key

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/cache/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Cache Settings",
    "cacheActive": true,
    "cacheKeyType": "CUSTOM",
    "cacheStorageType": "DISTRIBUTED",
    "capacity": 5000,
    "ttl": 7200,
    "handlingAction": "CONTINUE",
    "variableList": [
      {
        "name": "userId",
        "type": "HEADER",
        "dataType": "STRING"
      },
      {
        "name": "apiVersion",
        "type": "PARAMETER",
        "dataType": "STRING"
      }
    ]
  }'

Notes and Warnings

  • handlingAction: Required field. CONTINUE allows backend call for logging, STOP prevents backend call
  • Cache Key: When cacheKeyType=CUSTOM, provide variableList to define cache key components
  • Storage Type: LOCAL cache is faster but not shared; DISTRIBUTED cache is shared across workers
  • TTL: Cache entries expire after TTL seconds
  • Capacity: Maximum number of cache entries (older entries are evicted when limit reached)
  • GET Only: When cacheOnlyHttpGetRequests=true, only GET requests are cached (endpoint-level cache can override)
  • Null Values: When cacheNullValue=false, null/empty responses are not cached
  • Permissions: Requires ROLE_MANAGE_PROXIES permission