Caching
DomShot caches screenshots to reduce costs and improve response times.How it works
Every request is assigned a unique cache key. The API first checks if a cached screenshot exists for this key:- Cache found → Returns cached screenshot immediately (free)
- Cache not found → Captures new screenshot and saves to cache (1 credit)
Cache key generation
By default, cache keys are generated from:- HTTP method (
GET) - Full URL path with all query parameters
Custom cache keys
Override automatic cache key generation with thecacheKey parameter:
cacheKey is hashed before use, so any string value works.
Cache duration
Screenshots are cached for 4 hours. After expiration, the next request generates a new screenshot and refreshes the cache.Cache behavior
| Scenario | Credits | Description |
|---|---|---|
| Cache hit | Free | Cached screenshot returned |
| Cache miss | 1 credit | New screenshot captured and cached |
With fresh=true | 1 credit | Cache bypassed, new screenshot captured |
Bypassing cache
Usefresh=true to force a new screenshot and ignore cached results:
Best practices
- Leverage cache - Identical requests within 4 hours are free
- Use
fresh=truesparingly - Only when you need updated content - Custom cache keys - Group related screenshots under shared keys
See also
- How Credits Work - Credit consumption
- Rate Limits - Request rate limits