Menu
Docs/Caching

Caching

SnapSharp uses Redis to cache screenshots. Cached responses are served in under 50ms.

How it works

  1. A request arrives with url=https://example.com&width=1280&...
  2. We compute a SHA-256 hash of all parameters (excluding cache and cache_ttl)
  3. We check Redis: GET ss:cache:{hash}
  4. Cache hit → return cached image with X-Cache: HIT header
  5. Cache miss → capture screenshot → store in Redis → return with X-Cache: MISS

Response headers

X-Cache: HIT    # Served from Redis
X-Cache: MISS   # Fresh capture

Controlling cache behavior

Disable caching for a request:

?cache=false

Custom 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