Cache Management
RenderScreenshot caches screenshots for fast retrieval. These endpoints let you manage cached content programmatically.
Get Cached Screenshot
Retrieve a screenshot by its cache key.
GET https://api.renderscreenshot.com/v1/cache/:key
Example
curl https://api.renderscreenshot.com/v1/cache/cache_xyz789 \ -H "Authorization: Bearer rs_live_xxxxx" \ --output screenshot.png
Response
Returns the cached screenshot binary, or 404 if not found.
HTTP/1.1 200 OK Content-Type: image/png X-Cache-Hit: true X-Cache-Expires: 2024-01-19T00:00:00Z
Delete Cache Entry
Invalidate a single cached screenshot.
DELETE https://api.renderscreenshot.com/v1/cache/:key
Example
curl -X DELETE https://api.renderscreenshot.com/v1/cache/cache_xyz789 \ -H "Authorization: Bearer rs_live_xxxxx"
Response
{ "deleted": true, "key": "cache_xyz789" }
Bulk Purge
Invalidate multiple cache entries at once.
POST https://api.renderscreenshot.com/v1/cache/purge
Request Body
{ "keys": ["cache_abc", "cache_def"], "pattern": "screenshots/2024/01/*", "url": "https://example.com/*", "before": "2024-01-15T00:00:00Z" }
| Parameter | Type | Description |
|---|---|---|
keys |
array | Specific cache keys to purge |
pattern |
string | Glob pattern for storage paths |
url |
string | Glob pattern for source URLs |
before |
string | Purge entries created before this timestamp (ISO 8601) |
You can combine multiple filters. All matching entries will be purged.
Example: Purge by Keys
curl -X POST https://api.renderscreenshot.com/v1/cache/purge \ -H "Authorization: Bearer rs_live_xxxxx" \ -H "Content-Type: application/json" \ -d '{ "keys": ["cache_abc123", "cache_def456"] }'
Example: Purge by URL Pattern
curl -X POST https://api.renderscreenshot.com/v1/cache/purge \ -H "Authorization: Bearer rs_live_xxxxx" \ -H "Content-Type: application/json" \ -d '{ "url": "https://mysite.com/blog/*" }'
Example: Purge by Date
curl -X POST https://api.renderscreenshot.com/v1/cache/purge \ -H "Authorization: Bearer rs_live_xxxxx" \ -H "Content-Type: application/json" \ -d '{ "before": "2024-01-01T00:00:00Z" }'
Response
{ "purged": 42, "pattern": "https://mysite.com/blog/*" }
Cache Keys
Cache keys are returned in the X-Cache-Key response header when capturing screenshots:
X-Cache-Key: cache_xyz789 X-Cache-URL: https://cdn.renderscreenshot.com/xyz789.png
You can also set custom cache keys when creating screenshots:
{ "url": "https://example.com", "cache": { "key": "my-custom-key" } }
Use Cases
Force Refresh
To update a cached screenshot, set cache.refresh to true:
{ "url": "https://example.com", "cache": { "refresh": true } }
Clear on Deploy
Purge all cached screenshots for your domain after deploying updates:
curl -X POST https://api.renderscreenshot.com/v1/cache/purge \ -H "Authorization: Bearer rs_live_xxxxx" \ -H "Content-Type: application/json" \ -d '{"url": "https://yoursite.com/*"}'
Scheduled Cleanup
Purge old cache entries to ensure fresh content:
curl -X POST https://api.renderscreenshot.com/v1/cache/purge \ -H "Authorization: Bearer rs_live_xxxxx" \ -H "Content-Type: application/json" \ -d '{"before": "2024-01-01T00:00:00Z"}'