You're viewing Apigee Edge documentation.
View Apigee X documentation.
Apigee Edge mechanisms for caching and persistence include short-term and long-term persistence. There are policies for response caching and general purpose caching. Use the management API to manage caches.
Backend response caching
You can cache the response of a backend resource with the Response Cache policy.
This is especially helpful when backend data is updated only periodically. The ResponseCache policy can reduce calls to backend data sources.
Through the ResponseCache policy, you can also have Edge look at certain HTTP response caching
headers and take actions according to header directives. For example, on responses from backend
targets, Edge supports the
Cache-Control header. This header can be used to control
the maximum age of a cached response, among other things. For more information, see
Support for HTTP response headers.
Short-term general purpose caching
Using policies for general purpose caching, you can persist any objects your proxy requires across multiple request/response sessions.
For example, you might temporarily store:
- Session IDs for session management.
- Credentials for outbound calls (such as API keys or OAuth access tokens).
- Response content that must be paginated for apps.
At runtime, your cache policies copy values between proxy variables and the configured cache you specify. When a value is placed in the cache, it is copied from the variable you specify to the cache. When it is retrieved from the cache, it is copied into the variable for use by your proxy.
For an example with code, see Example: General purpose caching.
Long-term persistence with key value maps (KVMs)
To indefinitely store structured data either encrypted or unencrypted, you can create and populate key value maps (KVMs) that contain arbitrary key/value pairs. For example, you might store:
- A map correlating IP addresses to country codes.
- A list of IP addresses for allowlisting/denylisting.
- A map correlating long URLs to shortened URLs.
- Environment-specific data, such as quota counts and OAuth token expiration times.
KVMs can have one of three scopes: organization, environment, apiproxy. For example, if key/value pairs are to be used for all APIs in an organization, create a KVM at the organization scope; or if only a specific API proxy should have access to keys/values, create the KVM at the apiproxy scope. You can create, manage, and retrieve key value maps in a number of ways. For more information, see Working with key value maps.
Managing cache with the management API
If you want to create, view, update, delete, and clear cache outside the scope of policies in a message flow, you can use the Caches management API.