Cache Control
Views implement a caching system that stores query results in dedicated database tables for fast retrieval and extra filtering. You can control cache behavior through both view configuration and HTTP headers.
How View Caching Works
Views work like materialized views in traditional databases:
- User requests view data
- System looks for cached data in the view's database table
- If data exists and hasn't expired, return immediately
- Cache Miss/Expired: Execute view queries and wait up to
refreshTimeout
- Cache Miss/Expired: Execute view queries and wait up to
- Timeout Handling: If refresh exceeds timeout:
- Return stale data if available
- Return error if no cached data exists
- Hard Timeout Limit: Refresh operations have a hard limit of 1 minute regardless of configuration
Cache Configuration
View-Level Settings
Configure cache behavior in your view specification:
apiVersion: mission-control.flanksource.com/v1
kind: View
metadata:
name: my-view
spec:
cache:
maxAge: '30m' # Maximum cache age before refresh (default: 15m)
minAge: '30s' # Minimum age clients can request (default: 10s)
refreshTimeout: '10s' # How long to wait for refresh (default: 5s)
queries:
# ... your queries
Default Values
Setting | Default | Description |
---|---|---|
maxAge | 15 minutes | Cache expires after this duration |
minAge | 10 seconds | Minimum cache age that clients can request |
refreshTimeout | 5 seconds | Timeout for background refresh operations |
Hard Timeout Limit
Regardless of the configured refreshTimeout
, view refresh operations have a hard limit of 1 minute. This prevents long-running queries from blocking the system.