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
- First Browse: Archive contents loaded via
borg list(slow) - Cached: Results compressed and stored in Redis with TTL
- Subsequent Browses: Served instantly from cache (fast)
- Automatic Refresh: Cache expires after TTL, rebuilds on next access
Cache Architecture
- 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
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
Redis server hostname. Used if
REDIS_URL is not set.Set to "disabled" to disable Redis and use only in-memory cache.Redis server port.
Redis database number (0-15).
Redis server password (if authentication enabled).
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)
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.
- Redis URL (external Redis)
- Cache TTL
- Cache size limit
- Enable/disable caching
Redis Memory Configuration
Default Configuration
docker-compose.yml
| Flag | Purpose | Default |
|---|---|---|
--maxmemory | Maximum memory limit | 2GB |
--maxmemory-policy | Eviction policy when full | allkeys-lru |
--save "" | Disable RDB snapshots | Disabled |
--appendonly | Disable AOF persistence | Disabled |
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
allkeys-lfu: Evict least frequently used (better for hot data)volatile-lru: Only evict keys with TTL setvolatile-ttl: Evict keys with shortest TTL first
Memory Sizing
Estimation formula:- Archives 100KB: Automatically compressed (zlib level 6)
- Typical compression: 30-50% of original size
- Archives 100KB: Stored uncompressed
| Archives | Avg Size | Compressed | Recommended Redis |
|---|---|---|---|
| 100 | 1MB | ~40MB | 512MB |
| 500 | 5MB | ~1GB | 2GB |
| 1000 | 10MB | ~3GB | 4GB |
| 5000 | 2MB | ~3GB | 4GB |
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
- 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:00archive:5:weekly-2026-W09archive: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
| Feature | Redis | In-Memory |
|---|---|---|
| Persistence | Survives restart | Lost on restart |
| Shared | Multi-instance | Single instance |
| Size limit | Set via maxmemory | Set via CACHE_MAX_SIZE_MB |
| Eviction | Configurable | LRU only |
| Performance | Excellent | Good |
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:Redis Logs
Performance Metrics
Troubleshooting
Redis Connection Failed
Symptoms:- Check Redis is running:
- Check Redis logs:
- Restart Redis:
- Verify network:
Out of Memory
Symptoms:- Increase Redis memory:
- Lower TTL to expire data faster:
- Manually clear cache:
Slow Performance
Symptoms: Cache hit rate 80%, slow archive browsing Solutions:- Check hit rate:
- Increase TTL:
- Increase memory:
- Check Redis is actually being used:
Cache Not Updating
Symptoms: New archives not showing, stale data displayed Solutions:- Clear repository cache:
- Check TTL expiration:
- Verify archive name matches cache key
Best Practices
Use Redis for Production
Use Redis for Production
Always use Redis in production. The in-memory fallback is for emergency/testing only.
Set Appropriate TTL
Set Appropriate TTL
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)
Size Redis Appropriately
Size Redis Appropriately
Allocate 2-4x the average total archive size (compressed) for optimal hit rates.
Monitor Hit Rate
Monitor Hit Rate
Target 90%+ hit rate. If lower, increase memory or TTL.
Disable Persistence
Disable Persistence
Redis is a cache - disable RDB/AOF to improve performance and reduce disk I/O.
Clear After Major Changes
Clear After Major Changes
Manually clear cache after pruning, deleting archives, or restructuring repositories.
Use External Redis for Scale
Use External Redis for Scale
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