Caching
SnapSharp uses Redis to cache screenshots. Cached responses are served in under 50ms.
How it works
- A request arrives with
url=https://example.com&width=1280&... - We compute a SHA-256 hash of all parameters (excluding
cacheandcache_ttl) - We check Redis:
GET ss:cache:{hash} - Cache hit → return cached image with
X-Cache: HITheader - Cache miss → capture screenshot → store in Redis → return with
X-Cache: MISS
Response headers
X-Cache: HIT # Served from Redis
X-Cache: MISS # Fresh captureControlling cache behavior
Disable caching for a request:
?cache=falseCustom TTL (in seconds):
?cache_ttl=86400 # Cache for 24 hours
?cache_ttl=0 # Don't cache (same as cache=false)Default TTL is 3600 seconds (1 hour).
Cache limits
- Maximum cached image size: 5MB — larger images are not cached
- TTL range: 0 to 86400 seconds
- Responses are cached server-side; identical requests return cached results instantly
When to disable caching
Use cache=false when you need a fresh screenshot every time — for example, monitoring a dashboard that updates every minute.
- Real-time monitoring / screenshots that change frequently
- Authenticated pages with session-specific content
- Testing: when you want to see the actual current state of a page