MCP Cache Testing Guide
Comprehensive guide for testing, debugging, and optimizing cache behavior on Azion Platform using MCP tools and cURL commands.
This guide provides methods for testing, debugging, and optimizing cache behavior on the Azion Platform using MCP tools and direct cURL commands.
Cache debug headers
Enable cache debug headers by including Pragma: azion-debug-cache in your requests. This returns detailed cache information.
Debug headers reference
| Header | Description | Example Values |
|---|---|---|
X-Cache | Cache status of the request | HIT, MISS, EXPIRED, UPDATING, STALE |
X-Cache-Key | The cache key used to store/retrieve the object | /index.html@@cookie_name=value |
X-Cache-File | MD5 hash of the cache key | a1b2c3d4e5f6789... |
X-Cache-Since | Unix timestamp when object was cached | 1640995200 |
X-Cache-Expire | Unix timestamp when cache expires | 1640995800 |
X-Cache-Expire-In | Seconds remaining until cache expires | 600 |
X-Cache-Valid | Configured TTL in seconds | 3600 |
X-Cache-Config | Azion configuration ID | 1595368520 |
X-Cache-ID | Unique identifier for this request | #AECFE66100000000C947B9B3... |
Basic cache testing with cURL
Test Azion domain
Always start by testing the .map.azionedge.net domain directly:
Test static assets
Test production domain via Azion
Cache key testing
Query parameter variations
Cookie-based variations
Cache performance testing
Consistent location testing
Fix the IP to ensure both requests go to the same server:
Provider comparison
Network information
Get network information including your IP, resolver, and location:
This provides:
- Your public IP (useful for searching in Azion logs)
- DNS resolver being used
- Azion location serving the request
- Network health status
Real-Time Events monitoring
Using Azion CLI
Key log variables for cache analysis
| Variable | Description | Example |
|---|---|---|
Cache Key | Cache key used | /index.html@@cookie_name=value |
Cache TTL | Cache duration in seconds | 31536000 |
Upstream Cache Status | Cache status | HIT, MISS, BYPASS, EXPIRED, STALE |
Upstream Response Time | Origin response time | - for cached content |
Bytes Sent | Total bytes delivered | 1024 |
Request Time | Total processing time | 0.001 |
GraphQL queries for cache analysis
Use MCP’s create_graphql_query tool or run directly:
Key performance indicators
- Cache Hit Ratio: Should be >80% for static content
- Edge Offload: Percentage of requests served from cache vs origin
- Origin Response Time: Compare cached vs non-cached requests
- Bandwidth Savings: Bytes served from cache vs origin
Cache configuration via CLI
Create cache settings
Apply via Rules Engine
Cache optimization strategies
Query string strategy
| Strategy | Use case | Configuration |
|---|---|---|
| Ignore all | Static assets | --cache-by-query-string "ignore" |
| Whitelist | APIs with functional params | --cache-by-query-string "whitelist" with specific params |
| Blacklist | Ignore tracking params | --cache-by-query-string "blacklist" with utm_*, fbclid, gclid |
Cookie strategy
| Strategy | Use case | Configuration |
|---|---|---|
| Ignore all | Static content | --cache-by-cookies "ignore" |
| Whitelist | Personalized content | --cache-by-cookies "whitelist" with language, currency |
TTL strategy by content type
| Content Type | Recommended TTL | Example |
|---|---|---|
| Static assets | 30 days | 2592000 seconds |
| Semi-static | 1 hour | 3600 seconds |
| Dynamic | 5 minutes | 300 seconds |
| Real-time | 30 seconds | 30 seconds |
Automated cache health check script
Troubleshooting cache issues
Low cache hit ratio (< 60%)
Diagnosis:
Solutions:
- Configure
cache-by-query-stringtoignorefor static content - Use
whitelistfor cookies instead of caching by all cookies - Implement bypass rules for authenticated users
Stale content not updating
Diagnosis:
Solutions:
Dynamic content being cached
Diagnosis:
Solutions:
- Add bypass rule for personalized content paths
- Configure proper
cacheByCookiesettings - Use shorter TTLs for user-specific content
Best practices
- Use
Pragma: azion-debug-cachefor immediate cache debugging - Monitor Real-Time Events for cache behavior analysis
- Test cache key variations with different parameters/cookies
- Implement tiered TTL strategy based on content type
- Use stale-while-revalidate for better availability
- Monitor cache hit ratios and optimize configurations
- Purge strategically using wildcards and cache keys
- Test from multiple locations using direct IP connections
- Automate cache health checks with shell scripts
- Measure performance differences between cached and non-cached requests