This repository contains the configuration and setup to containerize the Prerender service using Docker. The service leverages prerender with Redis-backed caching (prerender-redis-cache-ng) to efficiently render JavaScript content for web crawlers.
- 🚀 High Performance: Chrome 142 with optimized flags for Docker
- 💾 Redis Cache: Persistent caching with Valkey/Redis for faster response times (24x faster on cache hits!)
- 🔄 Protocol-Agnostic: HTTP and HTTPS URLs share the same cache
- 🛡️ Certificate Handling: Configured to handle SSL certificate issues
- 🐳 Production Ready: Docker Compose setup with Valkey included
- Docker and Docker Compose installed on your system
- Download from here
# Clone the repository
git clone https://github.com/7a6163/prerender-docker
cd prerender-docker
# Start services (Prerender + Valkey/Redis)
docker-compose up -d
# Test the service
curl http://localhost:3000/render?url=http://example.comPull and run the image:
docker pull ghcr.io/7a6163/prerender
docker run -p 3000:3000 -e REDIS_URL=redis://your-redis-host:6379 ghcr.io/7a6163/prerenderNote: Without Redis, caching will not work. Use Docker Compose or provide a Redis instance.
To use the Prerender service, access it on localhost at port 3000:
# First request (will render and cache)
curl http://localhost:3000/render?url=http://example.com
# Second request (served from cache, ~24x faster!)
curl http://localhost:3000/render?url=http://example.comREDIS_URL: Redis connection URL (default:redis://localhost:6379)PAGE_TTL: Cache expiration time in seconds (default:86400= 1 day, set to0for no expiration)MAX_CONCURRENT_RENDERS: Maximum concurrent rendering processes (default:10)LOCK_TTL: Lock timeout in seconds for preventing duplicate renders (default:30)DISABLE_IMAGES: Disable image loading for faster rendering (default:false, set totruefor 2-5x speed boost)
The service implements intelligent request deduplication and concurrency management:
- Per-URL Locking: Only one request can render a specific URL at a time. Concurrent requests for the same URL receive a
429 Too Many Requestsresponse withRetry-After: 5header - Global Concurrency Limit: Maximum concurrent renders across all URLs (configurable via
MAX_CONCURRENT_RENDERS) - Automatic Retry: Clients receiving 429 should retry after the suggested delay. The second request will typically hit the cache and return instantly
Example:
10 concurrent requests for https://example.com/product/123
↓
Request 1: Renders (1-2s) → Caches → Returns 200
Request 2-10: Return 429 immediately (3ms)
↓
After 5 seconds, retry
↓
All requests: Return from cache (50ms) → 200
For SEO and crawler use cases where images are not needed, you can disable image loading for 2-5x faster rendering:
# compose.yml
environment:
- DISABLE_IMAGES=truePerformance comparison:
- With images: ~1.5-3 seconds per page
- Without images: ~300-600ms per page
When to use:
- ✅ SEO crawlers (Googlebot, Bingbot) - Only need text content
- ✅ Link preview generators - Just need meta tags
- ✅ High-traffic scenarios - Maximize throughput
- ❌ Social media previews - Need images for og:image
- ❌ Screenshot services - Need visual representation
The service uses prerender-redis-cache-ng for caching:
- Cache Keys: Protocol-agnostic (HTTP and HTTPS share same cache)
- Example: Both
http://example.comandhttps://example.comuse keyexample.com
- Example: Both
- Cache Invalidation: Supports DELETE requests to clear cache
# Clear single URL curl -X DELETE http://localhost:3000/render?url=http://example.com # Clear pattern (all URLs matching wildcard) curl -X DELETE http://localhost:3000/render?url=http://example.com/*
Configured with flags optimized for Docker and Chrome 142:
--no-sandbox: Required for Docker--ignore-certificate-errors: Handle SSL certificate issues--disable-features=AutoupgradeMixedContent,HttpsUpgrades: Prevent automatic HTTPS upgrade
Web Crawler → Prerender Service (Port 3000) → Chromium
↓
Redis Cache (Valkey)
Cache Performance:
- First request (no cache): ~1.5 seconds
- Second request (cached): ~0.06 seconds
- ~24x faster with cache!
The compose.yml includes:
-
prerender: The main Prerender service
- Node.js 24-alpine
- Chromium 142
- Port: 3000
-
valkey: Redis-compatible cache
- Valkey 9-alpine (Redis fork)
- Port: 6379
- Persistent storage with AOF
# Build locally
docker-compose build
# View logs
docker-compose logs -f prerender
# Stop services
docker-compose down