Skip to main content

Redis Caching Configuration

Borg UI includes an intelligent caching system that can provide 600x faster archive browsing using Redis. The cache system automatically compresses large archives and gracefully falls back to in-memory caching when Redis is unavailable.

Overview

Performance Impact

Redis caching transforms the browsing experience:Without cache: 5-10 seconds per archive (depending on size)With cache: ~10ms per archive (after first load)Speedup: Up to 600x faster for large archives

How It Works

  1. First Browse: Archive contents loaded via borg list (slow)
  2. Cached: Results compressed and stored in Redis with TTL
  3. Subsequent Browses: Served instantly from cache (fast)
  4. Automatic Refresh: Cache expires after TTL, rebuilds on next access

Cache Architecture

Dual Backend System:
  • Redis: Primary cache (persistent, shared across restarts)
  • In-Memory: Automatic fallback (when Redis unavailable)

Quick Setup

The default Docker Compose configuration includes Redis:
docker-compose.yml
Redis starts automatically with Borg UI. No additional configuration needed for local setup.

Configuration Options

Environment Variables

string
default:"none"
External Redis connection URL. Takes precedence over REDIS_HOST/REDIS_PORT.Formats:
  • TCP: redis://hostname:port/db
  • TCP with password: redis://:password@hostname:port/db
  • TLS: rediss://hostname:port/db
  • Unix socket: unix:///run/redis.sock?db=0
Examples:
string
default:"redis"
Redis server hostname. Used if REDIS_URL is not set.Set to "disabled" to disable Redis and use only in-memory cache.
integer
default:"6379"
Redis server port.
integer
default:"0"
Redis database number (0-15).
string
default:"none"
Redis server password (if authentication enabled).
integer
default:"7200"
Cache time-to-live in seconds. Archive data cached for this duration.Default: 2 hours (7200 seconds)Recommendations:
  • Static archives: 14400 (4 hours) or higher
  • Active backups: 3600 (1 hour) or lower
  • Development: 300 (5 minutes)
integer
default:"2048"
Maximum in-memory cache size in megabytes (fallback backend only).Default: 2GB (2048 MB)

UI Configuration

Cache settings can also be configured via Settings → Cache in the web UI.UI settings override environment variables and persist to the database.
Configurable via UI:
  • Redis URL (external Redis)
  • Cache TTL
  • Cache size limit
  • Enable/disable caching

Redis Memory Configuration

Default Configuration

docker-compose.yml
Flags explained:
Persistence is disabled because Redis is used purely as a cache. Data loss on restart is acceptable since the cache rebuilds automatically.

Eviction Policies

allkeys-lru (Recommended):
  • Evicts least recently used keys from all keys
  • Best for pure cache use case
  • Automatically removes old archives to make room
Alternatives:
  • allkeys-lfu: Evict least frequently used (better for hot data)
  • volatile-lru: Only evict keys with TTL set
  • volatile-ttl: Evict keys with shortest TTL first

Memory Sizing

Estimation formula:
Compression:
  • Archives 100KB: Automatically compressed (zlib level 6)
  • Typical compression: 30-50% of original size
  • Archives 100KB: Stored uncompressed
Examples:
Set maxmemory slightly higher than estimated to prevent constant evictions.

Adjusting Memory Limits

docker-compose.yml
.env

External Redis Setup

Shared Redis Instance

docker-compose.yml

Redis with Authentication

.env

TLS/SSL Connection

.env

Multiple Borg UI Instances

Share one Redis instance across multiple Borg UI deployments:
docker-compose.yml
Use different Redis databases (0-15) to isolate cache data between instances.

Cache Management

View Cache Statistics

UI: Settings → Cache → Statistics API:
Response

Clear Cache

Use cases:
  • After pruning archives
  • After deleting archives
  • Testing/troubleshooting
  • Repository structure changed

Cache Keys

Format: archive:{repo_id}:{archive_name} Examples:
  • archive:1:backup-2026-02-28T10:00:00
  • archive:5:weekly-2026-W09
  • archive:12:daily-monday

Manual Redis Access

In-Memory Fallback

When It Activates

Automatic fallback to in-memory cache when:
  • Redis connection fails
  • Redis not configured (REDIS_HOST=disabled)
  • Redis unavailable during startup
  • Redis fails 3+ consecutive operations

Limitations

Disabling Redis

.env
docker-compose.yml

Performance Tuning

Large Repositories (>1000 archives)

docker-compose.yml
.env

Very Large Archives (>500MB each)

.env

High-Traffic Deployments

Low-Memory Environments

.env

Monitoring

Health Checks

Redis health check:
Check status:

Redis Logs

Performance Metrics

Troubleshooting

Redis Connection Failed

Symptoms:
Solutions:
  1. Check Redis is running:
  2. Check Redis logs:
  3. Restart Redis:
  4. Verify network:

Out of Memory

Symptoms:
Solutions:
  1. Increase Redis memory:
  2. Lower TTL to expire data faster:
  3. Manually clear cache:

Slow Performance

Symptoms: Cache hit rate 80%, slow archive browsing Solutions:
  1. Check hit rate:
  2. Increase TTL:
  3. Increase memory:
  4. Check Redis is actually being used:

Cache Not Updating

Symptoms: New archives not showing, stale data displayed Solutions:
  1. Clear repository cache:
  2. Check TTL expiration:
  3. Verify archive name matches cache key

Best Practices

Always use Redis in production. The in-memory fallback is for emergency/testing only.
Balance freshness vs performance:
  • Static archives: Longer TTL (4-24 hours)
  • Active backups: Shorter TTL (1-2 hours)
  • Development: Very short TTL (5-30 minutes)
Allocate 2-4x the average total archive size (compressed) for optimal hit rates.
Target 90%+ hit rate. If lower, increase memory or TTL.
Redis is a cache - disable RDB/AOF to improve performance and reduce disk I/O.
Manually clear cache after pruning, deleting archives, or restructuring repositories.
Share one Redis instance across multiple Borg UI deployments for better resource utilization.

Next Steps

Environment Variables

Complete cache environment variable reference

Docker Compose

Advanced Docker Compose configurations

Performance Optimization

Advanced performance tuning guide

API Reference

Cache management API documentation