Caching website screenshots is a powerful technique to boost performance and minimize API usage. By storing screenshots of your web pages, you avoid generating the same screenshots repeatedly, which can be resource-intensive and slow down your operations.
Implementing screenshot caching not only speeds up the process but also reduces the load on your servers and network. This is particularly valuable for monitoring websites, quality assurance, and analytics where frequent screenshots of unchanged content can be avoided.
To enable caching for your website screenshots, use the ttl
(Time To Live) URL parameter to specify the duration in seconds for which the screenshot should be cached.
For example, setting &ttl=30
will cache the screenshot for 30 seconds. This means if you request the same screenshot within this period, you'll receive the cached version instead of generating a new one.
To request a screenshot of google.com and cache it for one day (86400 seconds), use the following request:
// Example request for a daily cached screenshot https://api.addscreenshots.com/screenshots
?apikey=YOUR_API_KEY
&ttl=86400
&url=google.com
Your API key can be found on the API Keys page. Need an API Key? Sign up to get started.
For internal applications, replace YOUR_API_KEY with your own unique API Key.
For public facing websites or hotlinks, generate a signed URL.
Here are some typical Time To Live (TTL) values for caching durations:
Cache Duration | URL Parameter |
---|---|
10 minutes | &ttl=600 |
1 hour | &ttl=3600 |
1 day | &ttl=86400 |
1 week | &ttl=604800 |
1 month | &ttl=2592000 |
By default, screenshots are not cached. This ensures that each request returns the most current version of the page, which is ideal for dynamic or frequently updated content. However, for static or less frequently changing pages, enabling caching can significantly enhance performance and reduce API consumption.
Yes, you can use your own Content Delivery Network (CDN) to cache screenshots. Storing screenshots on platforms like Azure Blob Storage or an AWS S3 Bucket and pointing your CDN to these storage accounts gives you full control over caching and delivery.
Here's a quick overview of the caching process:
Cached screenshots are stored using Cloudflare, ensuring efficient delivery and access.
Be aware of the following limitations:
Implementing caching for website screenshots offers significant benefits, including improved performance, reduced API usage, and lower operational costs. By avoiding redundant screenshot generation, you can streamline your processes and ensure faster access to static content.