Skip to main content

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:
  1. Cache found → Returns cached screenshot immediately (free)
  2. 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
This means identical requests (same URL and parameters) share the same cache.

Custom cache keys

Override automatic cache key generation with the cacheKey parameter:
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&cacheKey=my-custom-key"
The 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

ScenarioCreditsDescription
Cache hitFreeCached screenshot returned
Cache miss1 creditNew screenshot captured and cached
With fresh=true1 creditCache bypassed, new screenshot captured

Bypassing cache

Use fresh=true to force a new screenshot and ignore cached results:
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&fresh=true"
This always consumes 1 credit, even if a cached screenshot exists.

Best practices

  • Leverage cache - Identical requests within 4 hours are free
  • Use fresh=true sparingly - Only when you need updated content
  • Custom cache keys - Group related screenshots under shared keys

See also