Enterprise Feature

Cache Persistence

Never lose your warm cache. Instant recovery after restarts.
Snapshots for backup, sync, and pre-warming.

Zero Hot-Path ImpactAsync BackgroundCompressed Snapshots

The Cold Cache Problem

Every time you restart Varnish, you start with an empty cache. During deployments, updates, or crashes, your origin gets hammered by traffic that was previously cached.

100%
Cache Miss Rate
After restart
10-30min
Warm-up Time
For large catalogs
10x
Backend Load Spike
During warm-up

Trident Cache Persistence

Trident saves cache snapshots to disk in the background. On startup, it loads the previous cache state instantly. Your cache is warm before the first request arrives.

0ms
Added Latency
Async snapshots
<5s
Cache Load Time
100K entries
91%
Compression
With zstd

Simple Configuration

# trident.toml

[cache.persistence]
enabled = true
path = "/var/lib/trident/snapshots"
interval = "5m"              # Snapshot every 5 minutes
compression = "zstd"         # Compress snapshots (91% smaller)
keep_snapshots = 3           # Retain last 3 snapshots
load_on_startup = true       # Auto-load latest snapshot

[cache.persistence.graceful_shutdown]
save_on_exit = true          # Save final state on shutdown
timeout = "30s"              # Max time to save

Periodic Snapshots

  • • Background thread, zero impact
  • • Atomic writes (no corruption)
  • • SHA256 checksums for integrity

Graceful Shutdown

  • • Final snapshot on SIGTERM
  • • Complete cache state saved
  • • Perfect for rolling deploys

Snapshot Use Cases

🔄

Blue-Green Deployments

Export cache from blue environment, import to green. New deployment starts with warm cache.

trident snapshot export --to s3://bucket/cache.snap
🌍

Multi-Region Sync

Share cache snapshots between regions. US cache warms EU servers instantly.

trident snapshot import --from s3://bucket/us-cache.snap
🧪

Test Environment Warming

Load production cache snapshots in staging. Test with realistic cache state.

trident snapshot load /snapshots/prod-latest.snap
📊

Capacity Planning

Analyze snapshot contents. See which tags use most memory.

trident snapshot analyze --group-by tag
💾

Disaster Recovery

Backup snapshots to S3/GCS. Restore cache after infrastructure failures.

trident snapshot restore --from backup-2024-01-15.snap
🚀

Canary Testing

Pre-load new origin responses before full rollout. Validate cache behavior.

trident snapshot merge --from canary.snap --to prod.snap

Snapshot CLI

# List available snapshots
$ trident-snap list
TIMESTAMP            SIZE      ENTRIES   COMPRESSION
2024-01-15 10:30:00  245 MB    150,432   zstd (91%)
2024-01-15 10:25:00  248 MB    149,891   zstd (91%)
2024-01-15 10:20:00  251 MB    148,234   zstd (91%)

# Create manual snapshot
$ trident-snap create --compress
Snapshot saved: /var/lib/trident/snapshots/snap-1705315800.zst
Entries: 150,432 | Size: 245 MB | Time: 2.3s

# Load specific snapshot
$ trident-snap load snap-1705315800.zst
Loading snapshot...
Entries loaded: 150,432 | Time: 4.1s | Memory: 1.2 GB

# Analyze snapshot contents
$ trident-snap analyze snap-1705315800.zst --top 10
TAG                  ENTRIES    SIZE      % OF CACHE
product:*            45,231     89 MB     36.3%
category:*           12,892     45 MB     18.4%
cms:block:*           8,234     23 MB      9.4%
...

# Export to remote storage
$ trident-snap export --to s3://my-bucket/cache-backup.snap
Uploading... Done (245 MB in 12s)

REST API for Automation

Create Snapshot

POST /admin/snapshot/create
Content-Type: application/json

{"compress": true, "name": "pre-deploy-backup"}

Response:
{
  "status": "success",
  "snapshot": {
    "name": "pre-deploy-backup",
    "path": "/var/lib/trident/snapshots/pre-deploy-backup.zst",
    "entries": 150432,
    "size_bytes": 256901120,
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Load Snapshot

POST /admin/snapshot/load
Content-Type: application/json

{"name": "pre-deploy-backup", "merge": false}

Response:
{
  "status": "success",
  "entries_loaded": 150432,
  "duration_ms": 4100,
  "memory_used_bytes": 1288490188
}

Availability Comparison

ProductCache PersistenceSnapshots
Trident Velocity✓ Built-in✓ Full CLI + API
Varnish OSS✗ Not available✗ Not available
Varnish Plus✗ Not available✗ Not available
Nginx✗ Not available✗ Not available
HAProxy✗ Not available✗ Not available

Never Start Cold Again

Cache persistence is included in Professional and Enterprise plans.