Documentation Index
Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
Use this file to discover all available pages before exploring further.
Cache Component Concept
Performance Improvement
Backend Load
High Availability
Cost Savings
Cache Component Types
Local Cache
Configuration Cache
Configuration Cache
- API Proxy configurations
- Policy definitions
- Routing information
- Metadata information
Token Cache
Token Cache
- OAuth2/JWT tokens
- Token validation results
- User session information
Response Cache
Response Cache
- API responses
- Cache key-based storage
- TTL (Time To Live) management
- Can be configured as local or distributed
Distributed Cache (Hazelcast)
Hazelcast
- Multi-node support
- High availability
- Management and monitoring can be done in Apinizer
- Can run in independent namespaces from Gateway pods
Shared State
- Throttling data
- Quota data
- Shared state information
- Cross-namespace access support
Response Cache
- Local response cache: Hazelcast is not used
- Distributed response cache: Hazelcast is used
Cache Invalidation
- Automatic invalidation
- Event-based invalidation
- Pattern-based invalidation
http://cache-http-service.apinizer-cache.svc.cluster.local:8090). This provides more flexible infrastructure management and allows you to separate Gateway and Cache workloads. For Cache Server configuration, see the Distributed Cache page.Cache Strategies
Cache-Aside (Lazy Loading)
- Search in cache
- If not found, get from backend
- Save to cache
- Return to client
Write-Through
- Write to backend
- Write to cache
- Return to client
Write-Back (Write-Behind)
- Write to cache
- Return to client
- Write to backend asynchronously
Cache Configuration
Cache Key Strategy
URL Based
GET /api/v1/products → Cache Key: /api/v1/productsQuery Parameter
GET /api/v1/products?category=electronics → Cache Key: /api/v1/products?category=electronicsHeader Based
Custom Key
Cache TTL (Time To Live)
Fixed TTL
Fixed TTL
- Keeping in cache for a specific period
- Example: 5 minutes, 1 hour
Dynamic TTL
Dynamic TTL
- TTL based on response headers
- Cache-Control header
- Expires header
Conditional TTL
Conditional TTL
- Conditional TTL
- Based on response status code
- Based on content type
Cache Invalidation
TTL Expiry
- Automatic deletion with timeout
Manual Invalidation
- Manual cache clearing
- Invalidation via API
Event-Based
- Event-based invalidation
- Invalidation with webhook
Pattern-Based
- Pattern-based invalidation
- Wildcard invalidation
Cache Usage Scenarios
Response Caching
- First request: Get from backend, save to cache
- Subsequent requests: Return from cache
- After TTL: Clear cache, get from backend again
Token Caching
- Token validation: Check if token exists in cache
- If in cache: Return without validation
- If not in cache: Validate from Identity Manager, save to cache
Configuration Caching
- API Proxy configuration: Get from Management API
- Save to local cache
- On configuration change: Invalidate cache
Throttling and Quota
- Throttling and quota data are stored in distributed cache
- Shared among all API Gateway instances (even if in different namespaces)
- Synchronized via Hazelcast
- Gateway pods access cache servers in different namespaces via Kubernetes service discovery
Cache Best Practices
TTL Management
- Select appropriate TTL values
- Too short TTL reduces performance
- Too long TTL risks stale data
Cache Key Design
- Meaningful cache keys
- Prevent collisions
- Pattern-based invalidation
Memory Management
- Cache size limits
- Eviction policies
- Memory monitoring
Error Handling
- Fallback on cache errors
- Routing to backend
- Error logging

