Flow Configuration Template
This document provides the configuration template for implementing the Caching Flow, enabling efficient and reliable caching of API responses based on URLs, query parameters, headers, and other request properties.
Flow Configuration
name: CachingFlow
filter:
url: api.example.com/v1/resources/* # Define the URL pattern for caching specific API endpoints. Note: this can also be set to an IP instead of a DNS.
processors:
ReadCache:
processor: ReadCache # Reads responses from the cache if available.
parameters:
- key: caching_key_parts
value:
- $.request.header.api_key
- $.request.query_param.resource_id
- $.request.url.path_param.organization
WriteCache:
processor: WriteCache # Writes responses to the cache.
parameters:
- key: ttl_seconds
value: 600 # Cache time-to-live set to 10 minutes.
- key: record_max_size_bytes
value: 8192 # Maximum size of cached responses is 8 KB.
- key: max_cache_size_megabytes
value: 200 # Cache size limited to 200 MB.
- key: caching_key_parts
value:
- $.request.header.api_key
- $.request.query_param.resource_id
- $.request.url.path_param.organization
flow:
request:
- from:
stream:
name: globalStream
at: start
to:
processor:
name: ReadCache
- from:
processor:
name: ReadCache
condition: cache_miss
to:
stream:
name: globalStream
at: end
response:
- from:
stream:
name: globalStream
at: start
to:
processor:
name: WriteCache
- from:
processor:
name: WriteCache
to:
stream:
name: globalStream
at: end
- from:
processor:
name: ReadCache
condition: cache_hit
to:
stream:
name: globalStream
at: end
Processor Configuration Tables
ReadCache Processor
Parameter | Description | Type | Mandatory/Optional | Example |
---|---|---|---|---|
caching_key_parts | Key used to normalize the API request path for caching. | String | Mandatory | "api.example.com/v1/resources" |
WriteCache Processor
Parameter | Description | Type | Mandatory/Optional | Example |
---|---|---|---|---|
ttl_seconds | Cache time-to-live in seconds. | Integer | Mandatory | 600 |
record_max_size_bytes | Maximum size of cached responses, in bytes. | Integer | Mandatory | 8192 |
max_cache_size_megabytes | Maximum size of the cache created by this processor, in megabytes. | Integer | Optional (default: 100) | 200 |
caching_key_parts | Key used to normalize the API request path for caching. | String | Mandatory | "api.example.com/v1/resources" |