On this page

    Run in production

    Reuse Screenshots for 0 Credits

    Stop paying twice for the same image: turn on cache.available, embed the free X-Cache-URL link, pick a TTL, and purge when the page changes.

    Time
    10 minutes
    Plan
    Free
    You need
    • An API key in RS_API_KEY

    What you will have at the end

    A request that reuses an earlier render: Cached: Yes, Credits used: 0.

    Every successful render uses one credit. Every render is also stored, and you can get it back for free. You will turn on reuse, pick a cache time, and use the free CDN link where you can.

    flowchart LR
      A[Request] --> B{cache.available<br/>and same options<br/>rendered within TTL?}
      B -- yes --> C[Earlier image<br/>0 credits]
      B -- no --> D[New render<br/>1 credit]
      D --> E[Stored on the CDN<br/>X-Cache-URL]
      C --> E
    

    Turn on reuse

    Add "cache": { "available": true }. If your account rendered exactly the same options within the cache time, the API returns that image and charges nothing:

    curl -X POST https://api.renderscreenshot.com/v1/screenshot \
      -H "Authorization: Bearer $RS_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://renderscreenshot.com/pricing", "preset": "og_card", "cache": {"available": true, "ttl": 604800}}' \
      -D - --output pricing.png
    

    These are the real headers of the same request sent twice. The first one renders, the second one reuses:

    HTTP/1.1 200 OK
    x-cache-hit: false
    x-cache-key: screenshots/a/809e9f57c5583e708cff/g/d1fa6d86f3cbd20379f84cfcd5ea5a21.png
    x-cache-expires: Mon, 02 Nov 2026 02:16:26 GMT
    x-credits-used: 1
    
    HTTP/1.1 200 OK
    x-cache-hit: true
    x-cache-key: screenshots/a/809e9f57c5583e708cff/g/d1fa6d86f3cbd20379f84cfcd5ea5a21.png
    x-cache-expires: Mon, 02 Nov 2026 02:16:26 GMT
    x-credits-used: 0
    

    In the SDKs:

    Node.js

    const image = await client.take(
      TakeOptions.url('https://renderscreenshot.com/pricing').preset('og_card').cacheAvailable().cacheTtl(604800)
    );
    

    Python

    image = client.take(
        TakeOptions.url('https://renderscreenshot.com/pricing').preset('og_card').cache_available().cache_ttl(604800)
    )
    

    Ruby

    image = client.take(
      RenderScreenshot::TakeOptions.url('https://renderscreenshot.com/pricing').preset('og_card').cache_available.cache_ttl(604_800)
    )
    

    GET and signed URLs

    # cache_available=true and cache_ttl work in GET requests and in signed URLs
    curl "https://api.renderscreenshot.com/v1/screenshot?url=https%3A%2F%2Frenderscreenshot.com%2Fpricing&preset=og_card&cache_available=true&cache_ttl=604800" \
      -H "Authorization: Bearer $RS_API_KEY" --output pricing.png
    

    "Exactly the same options" means every rendering option: URL (with its query string), preset, viewport, format, wait and block settings. Change any of them and the request renders again. The cache settings themselves (cache.ttl) and the storage settings are not compared.

    Choose how long to reuse a render

    cache.ttl is in seconds, from 3,600 (1 hour) to 2,592,000 (30 days). The default is 86,400 (24 hours). Pick it from how often the page changes:

    Page TTL Value
    A news front page, a dashboard 1 hour 3600
    A product page, a pricing page 1 day 86400
    A blog post, docs page, share image 30 days 2592000

    The TTL also sets how long the CDN link from step 3 is kept.

    Each response has an X-Cache-URL header (in JSON: cache.url). It is a public link to the image on the CDN. Loading it needs no key and costs no credits, until X-Cache-Expires.

    So when you show the same image many times, do not call the API each time. Call it once, save the link, and put the link in your page:

    <img src="https://cdn.renderscreenshot.com/screenshots/a/809e9f57c5583e708cff/g/d1fa6d86f3cbd20379f84cfcd5ea5a21.png"
         width="1200" height="630" alt="Pricing page preview" loading="lazy">
    

    When the link expires, call the API again with cache.available and save the new link. If the render is still in the cache, that call costs nothing.

    The link is public. Anyone who has it can open the image. For private pages, see capture pages behind a login.

    Purge when the page changes

    When you change a page, delete its stored renders so the next request renders it fresh:

    # Every render of every page under /blog/
    curl -X POST https://api.renderscreenshot.com/v1/cache/purge \
      -H "Authorization: Bearer $RS_API_KEY" -H "Content-Type: application/json" \
      -d '{"url": "https://renderscreenshot.com/blog/*"}'
    
    # One render, by the X-Cache-Key value
    curl -X DELETE "https://api.renderscreenshot.com/v1/cache/screenshots/a/809e9f57c5583e708cff/g/d1fa6d86f3cbd20379f84cfcd5ea5a21.png" \
      -H "Authorization: Bearer $RS_API_KEY"
    

    The response says how many renders it removed, for example {"purged": 12, "url": "https://renderscreenshot.com/blog/*"}. Run the purge from your deploy script, after the new version is live. Cache invalidation has examples for common deploy tools.

    Next steps

    Try RenderScreenshot free

    150 free credits every month, no credit card required.