REST Admin API
Full cache control via HTTP. No CLI access required.
Integrate with any CI/CD pipeline in minutes.
Quick Start
# Purge a single URL
curl -X POST http://localhost:8080/admin/purge/url \
-H "Content-Type: application/json" \
-d '{"url": "/products/123", "mode": "soft"}'
# Response
{
"status": "success",
"message": "URL purged",
"url": "/products/123",
"mode": "soft"
}
# Check cache stats
curl http://localhost:8080/stats
# Response
{
"entries": 15234,
"memory_used_mb": 892,
"hit_rate": 0.943,
"requests_total": 1523456
}API Reference
Cache Purge
/admin/purge/urlPurge a single URL from cache
{"url": "/path", "mode": "soft|hard"}/admin/purge/urlsBulk purge multiple URLs (68x faster than individual)
{"urls": ["/path1", "/path2", ...], "mode": "soft"}/admin/purge/tagPurge all entries with a specific tag
{"tag": "product:123", "mode": "soft"}/admin/purge/tagsMulti-tag purge with AND/OR logic
{"tags": ["tag1", "tag2"], "mode": "and|or", "purge_mode": "soft"}/admin/purge/tag/patternPurge using wildcard or regex patterns
{"pattern": "product:*", "type": "wildcard|regex", "mode": "soft"}/admin/cache/clearClear entire cache (use with caution)
Cache Inspection
/admin/cache/entry?url=/pathInspect a specific cache entry
{
"url": "/products/123",
"status": 200,
"ttl_remaining": "45m32s",
"age": "14m28s",
"hits": 1523,
"size_bytes": 24567,
"tags": ["product:123", "category:electronics"],
"vary": ["X-Customer-Group"],
"compressed": true
}/admin/tags/statsGet cache usage grouped by tag
{
"total_tags": 15234,
"top_tags": [
{"tag": "product:*", "entries": 45231, "size_mb": 89},
{"tag": "category:*", "entries": 12892, "size_mb": 45}
]
}Monitoring
/statsJSON statistics for application integration
{
"uptime_seconds": 86400,
"requests_total": 1523456,
"cache_hits": 1436789,
"cache_misses": 86667,
"hit_rate": 0.943,
"entries": 15234,
"memory_used_mb": 892,
"memory_limit_mb": 4096,
"backends": {
"origin": {"healthy": true, "requests": 86667}
}
}/metricsPrometheus format for Grafana dashboards
# HELP trident_requests_total Total requests
# TYPE trident_requests_total counter
trident_requests_total 1523456
# HELP trident_cache_hit_ratio Cache hit ratio
# TYPE trident_cache_hit_ratio gauge
trident_cache_hit_ratio 0.943/healthHealth check endpoint for load balancers
Snapshots (Enterprise)
/admin/snapshot/createCreate a cache snapshot
/admin/snapshot/loadLoad a cache snapshot
/admin/snapshot/listList available snapshots
Integration Examples
GitHub Actions / CI Pipeline
# .github/workflows/deploy.yml
- name: Purge cache after deploy
run: |
curl -X POST https://trident.example.com:8080/admin/purge/tag \
-H "Authorization: Bearer $TRIDENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"tag": "deploy:latest", "mode": "soft"}'PHP / Laravel
// After product update
$client = new GuzzleHttp\Client();
$response = $client->post('http://trident:8080/admin/purge/tag', [
'json' => [
'tag' => "product:" . $product->id,
'mode' => 'soft'
]
]);
// Check result
$result = json_decode($response->getBody());
Log::info("Purged " . $result->entries_purged . " cache entries");Node.js / JavaScript
// trident-client.js
async function purgeProduct(productId) {
const response = await fetch('http://trident:8080/admin/purge/tag', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
tag: 'product:' + productId,
mode: 'soft'
})
});
return response.json();
}
// Usage
await purgeProduct(123);Authentication
Secure your admin API with token authentication. Tokens are configured in trident.toml and passed via Authorization header.
# trident.toml
[admin]
listen = "127.0.0.1:8080"
auth_token = "your-secret-token-here"
# Request with auth
curl -X POST http://localhost:8080/admin/purge/tag \
-H "Authorization: Bearer your-secret-token-here" \
-H "Content-Type: application/json" \
-d '{"tag": "product:123"}'Best Practice: Keep admin API on internal network only (127.0.0.1 or private IP). Use a reverse proxy with mTLS for external access.
Automate Your Cache Operations
REST Admin API is included in all Trident plans.