Ana içeriğe atla

Endpoint

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

Authentication

Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI 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

FieldTypeRequiredDefaultDescription
namestringYes-Cache settings name
descriptionstringNo-Cache settings description
cacheActivebooleanNofalseEnable/disable cache
cacheOnlyHttpGetRequestsbooleanNotrueCache only GET requests (if false, caches all methods)
cacheKeyTypestringNoQUERY_PARAMSCache key type
cacheStorageTypestringNoDISTRIBUTEDCache storage type
capacityintegerNo-Maximum cache capacity (number of entries)
ttlintegerNo-Time to live in seconds
handlingActionstringYes-Cache handling action when cache hit occurs
invalidationRequiresAuthnbooleanNofalseRequire authentication for cache invalidation
cacheNullValuebooleanNofalseCache null/empty responses
variableListarrayNo[]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

FieldTypeDescription
successbooleanIndicates 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

User must have API_MANAGEMENT + MANAGE permission in the project.