Developer-Friendly

REST Admin API

Full cache control via HTTP. No CLI access required.
Integrate with any CI/CD pipeline in minutes.

RESTfulJSON ResponsesToken Auth

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

POST/admin/purge/url

Purge a single URL from cache

{"url": "/path", "mode": "soft|hard"}
POST/admin/purge/urls

Bulk purge multiple URLs (68x faster than individual)

{"urls": ["/path1", "/path2", ...], "mode": "soft"}
POST/admin/purge/tag

Purge all entries with a specific tag

{"tag": "product:123", "mode": "soft"}
POST/admin/purge/tags

Multi-tag purge with AND/OR logic

{"tags": ["tag1", "tag2"], "mode": "and|or", "purge_mode": "soft"}
POST/admin/purge/tag/pattern

Purge using wildcard or regex patterns

{"pattern": "product:*", "type": "wildcard|regex", "mode": "soft"}
POST/admin/cache/clear

Clear entire cache (use with caution)

Cache Inspection

GET/admin/cache/entry?url=/path

Inspect 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
}
GET/admin/tags/stats

Get 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

GET/stats

JSON 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}
  }
}
GET/metrics

Prometheus 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
GET/health

Health check endpoint for load balancers

Snapshots (Enterprise)

POST/admin/snapshot/create

Create a cache snapshot

POST/admin/snapshot/load

Load a cache snapshot

GET/admin/snapshot/list

List 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.