Deploying Lancache
Introduction
Lancache is an open source caching solution designed specifically for game downloads from major platforms like Steam, Epic Games Store, Origin, Battle.net, and many others. Originally designed for LAN parties and gaming events, Lancache reduces bandwidth usage and dramatically speeds up game downloads by caching content locally.
When multiple users download the same game or update, Lancache serves the content from its local cache instead of downloading from the internet repeatedly. This is invaluable for events, gaming cafes, households with multiple gamers, or organizations with limited bandwidth.
Key features of Lancache:
- Multi-Platform Support: Steam, Epic, Origin, Battle.net, Uplay, Xbox, PlayStation, Nintendo
- Massive Bandwidth Savings: Cache once, serve many times
- Fast Downloads: Local network speeds for cached content
- Automatic Updates: Cached content updated transparently
- DNS-Based Routing: Works with any client without configuration
- Monolithic or Split Mode: Single cache or per-service caches
- Statistics Dashboard: Monitor cache hits and bandwidth savings
- Prefill Support: Pre-download games before events
- Open Source: Community-driven development
- Docker-Based: Easy deployment and management
This guide walks through deploying Lancache on Klutch.sh using Docker, configuring DNS, and maximizing your cache efficiency.
Why Deploy Lancache on Klutch.sh
Deploying Lancache on Klutch.sh provides several advantages for game download caching:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds Lancache without complex orchestration.
Massive Storage: Attach large persistent volumes to cache hundreds of gigabytes of game content.
Always Available: Your cache is accessible 24/7, not just during events.
GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.
Scalable Resources: Allocate CPU and memory based on expected concurrent users.
Environment Variable Management: Securely store configuration without exposing in code.
Custom Domains: Assign domains for the cache and DNS services.
Persistent Cache: Game downloads survive container restarts.
Prerequisites
Before deploying Lancache on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- Basic familiarity with Docker, DNS, and networking
- Ability to configure DNS on your network
- Large storage capacity for game cache
- (Optional) Upstream DNS server address
Preparing Your Repository
Create a GitHub repository containing your Dockerfile for deploying Lancache on Klutch.sh.
Repository Structure
lancache-deploy/├── Dockerfile├── README.md└── .dockerignoreCreating the Dockerfile
Create a Dockerfile for the Lancache monolithic container:
FROM lancachenet/monolithic:latest
# Set environment variablesENV CACHE_MEM_SIZE=500mENV CACHE_DISK_SIZE=1000gENV CACHE_MAX_AGE=3650d
# Create cache directoryRUN mkdir -p /data/cache /data/logs
# Expose HTTP portEXPOSE 80
# The base image includes the default entrypointEnvironment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
CACHE_MEM_SIZE | No | 500m | Memory for caching metadata |
CACHE_DISK_SIZE | Yes | - | Maximum disk cache size |
CACHE_MAX_AGE | No | 3650d | Maximum age of cached content |
UPSTREAM_DNS | No | 8.8.8.8 | Upstream DNS server |
CACHE_DOMAINS_REPO | No | - | Custom cache domains repository |
NGINX_WORKER_PROCESSES | No | auto | Number of nginx workers |
CACHE_INDEX_SIZE | No | 500m | Size of cache index in memory |
Deploying Lancache on Klutch.sh
- Select HTTP as the traffic type
- Set the internal port to 80
- Detect your Dockerfile automatically
- Build the container image
- Attach the persistent volumes
- Start the Lancache container
- Provision an HTTPS certificate
Push Your Repository to GitHub
Initialize your repository and push to GitHub:
git initgit add Dockerfile .dockerignore README.mdgit commit -m "Initial Lancache deployment configuration"git remote add origin https://github.com/yourusername/lancache-deploy.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “lancache” or “game-cache”.
Create a New App
Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your Lancache Dockerfile.
Configure HTTP Traffic
In the deployment settings:
Set Environment Variables
Add the following environment variables:
| Variable | Value |
|---|---|
CACHE_MEM_SIZE | 500m |
CACHE_DISK_SIZE | 1000g (adjust to your volume size) |
CACHE_MAX_AGE | 3650d |
UPSTREAM_DNS | 8.8.8.8 |
Attach Persistent Volumes
Add volumes for cache storage:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/data/cache | 1+ TB | Cached game downloads |
/data/logs | 10 GB | Access and error logs |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Note Your IP Address
Record the IP address of your Lancache deployment for DNS configuration.
DNS Configuration
Setting Up Lancache DNS
For Lancache to work, client devices need to use DNS that redirects game download requests to your cache. You have several options:
Option 1: Use Lancache DNS Container
Deploy the Lancache DNS container separately and point clients to it.
Option 2: Configure Your Router
Many routers support custom DNS entries. Add entries for game CDN domains pointing to your Lancache IP.
Option 3: Local DNS Server
If you run Pi-hole or similar, add custom DNS records for game CDNs.
Supported Services
Lancache caches downloads from:
| Service | Description |
|---|---|
| Steam | Steam game downloads |
| Epic | Epic Games Store |
| Origin | EA Origin/EA App |
| Battle.net | Blizzard games |
| Uplay | Ubisoft Connect |
| Xbox | Microsoft/Xbox downloads |
| PlayStation | PlayStation Network |
| Nintendo | Nintendo Switch updates |
| Riot | League of Legends, Valorant |
| Rockstar | Rockstar Games Launcher |
Monitoring Your Cache
Checking Cache Statistics
View cache performance:
- Check Lancache logs for HIT/MISS ratios
- Monitor disk usage of cache volume
- Track bandwidth savings over time
Understanding Cache Behavior
| Log Entry | Meaning |
|---|---|
| HIT | Served from cache |
| MISS | Downloaded from origin |
| EXPIRED | Cache entry expired, re-downloading |
| BYPASS | Content not cached |
Prefilling Your Cache
Using Steam Prefill
Download games before events:
docker run -it --rm \ -v /data/cache:/data/cache \ tpill90/steam-lancache-prefill:latest \ prefill --appids 730,570,440Using Epic Prefill
Pre-cache Epic games:
docker run -it --rm \ -v /data/cache:/data/cache \ tpill90/epic-lancache-prefill:latest \ prefillTroubleshooting Common Issues
Cache Not Working
- Verify DNS is correctly redirecting traffic
- Check that clients are using your DNS server
- Ensure firewall allows traffic to Lancache
Slow Downloads
- Check cache HIT rate in logs
- Verify sufficient disk I/O
- Ensure network isn’t bottlenecked
Disk Space Issues
- Monitor cache size vs allocated space
- Adjust CACHE_DISK_SIZE if needed
- Consider enabling cache cleanup
Additional Resources
Conclusion
Deploying Lancache on Klutch.sh gives you a powerful game download caching solution with persistent storage and automatic builds. Save bandwidth and speed up downloads for your gaming setup, whether for events or everyday use.