---
title: "Cached & Fresh Screenshot | ScreenshotAPI Docs"
slug: "/docs/renderScreenshot/cached-and-fresh-screenshot"
description: "Understand the difference between cached and fresh and how to control caching behavior to optimize performance and speed when capturing website screenshots."
---

# Cached & Fresh Screenshot

When you enable the `enable_caching` option, the system optimizes performance by reducing the need to repeatedly generate new screenshots for the same request. On the first request for a specific URL (along with its parameters), the API captures a fresh screenshot and stores it in the cache. For any subsequent requests with the same URL and identical parameters, if `fresh=false`, the system will not generate a new screenshot. Instead, it will return the previously cached version.

This significantly improves response time and reduces processing overhead, making it ideal for use cases where the webpage content does not change frequently. By leveraging caching, you can achieve faster results, lower resource usage, and more efficient large-scale screenshot operations while still having the option to force a new capture whenever needed.

**Example:**

```js

const axios = require("axios");

let config = {
	method: "get",
	maxBodyLength: Infinity,
	url: "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&output=image&file_type=png&enable_caching=true&wait_for_event=load&[OPTIONS]",
	headers: { }
};

axios.request(config).then((response) => {
	console.log(JSON.stringify(response.data));
}.catch((error) => {
	console.log(error);
});
```

```php

<?php
	$client = new http.Client;
	$request = new http.Client.Request;
	$request->setRequestUrl("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&output=image&file_type=png&enable_caching=true&wait_for_event=load&[OPTIONS]");
	$request->setRequestMethod("GET");
	$request->setOptions(array());

	$client->enqueue($request)->send();
	$response = $client->getResponse();
	echo $response->getBody();
?>
```

```go

package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {
	url := "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&output=image&file_type=png&enable_caching=true&wait_for_event=load&[OPTIONS]"
	method := "GET"

	client := &http.Client { }
	req, err := http.NewRequest(method, url, nil)

	if err != nil {
		fmt.Println(err)
		return
	}

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}

	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}
```

```java

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder().url("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&output=image&file_type=png&enable_caching=true&wait_for_event=load&[OPTIONS]"
	.method("GET", body)
	.build();
Response response = client.newCall(request)
	.execute();
```

```py

import requests

url = "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&output=image&file_type=png&enable_caching=true&wait_for_event=load&[OPTIONS]"
payload = {}
headers = {}

response = requests.request("GET", url, headers, data=payload)
print(response.text)
```

```ruby

require "uri"
require "net/http"

url = URI("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&output=image&file_type=png&enable_caching=true&wait_for_event=load&[OPTIONS]")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)

response = https.request(request)
puts response.read_body
```

To take a new screenshot and bypass the cache, you can pass `fresh=true` in your request. When this parameter is enabled, the system ignores any previously stored (cached) version of the screenshot and forces a new capture directly from the live webpage.

This is particularly important for pages with frequently changing or dynamic content such as dashboards, pricing pages, news sites, or user-specific data, where relying on a cached version could return outdated information. By using `fresh=true`, you ensure that the screenshot always reflects the most current state of the page at the time of the request.

While this guarantees up-to-date results, it may take slightly longer than returning a cached screenshot, as the system needs to render the page again. Therefore, it is best used only when accuracy is more critical than speed.

**Example:**

```js

const axios = require("axios");

let config = {
	method: "get",
	maxBodyLength: Infinity,
	url: "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&[OPTIONS]",
	headers: { }
};

axios.request(config).then((response) => {
	console.log(JSON.stringify(response.data));
}.catch((error) => {
	console.log(error);
});
```

```php

<?php
	$client = new http.Client;
	$request = new http.Client.Request;
	$request->setRequestUrl("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&[OPTIONS]");
	$request->setRequestMethod("GET");
	$request->setOptions(array());

	$client->enqueue($request)->send();
	$response = $client->getResponse();
	echo $response->getBody();
?>
```

```go

package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {
	url := "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&[OPTIONS]"
	method := "GET"

	client := &http.Client { }
	req, err := http.NewRequest(method, url, nil)

	if err != nil {
		fmt.Println(err)
		return
	}

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}

	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}
```

```java

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder().url("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&[OPTIONS]"
	.method("GET", body)
	.build();
Response response = client.newCall(request)
	.execute();
```

```py

import requests

url = "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&[OPTIONS]"
payload = {}
headers = {}

response = requests.request("GET", url, headers, data=payload)
print(response.text)
```

```ruby

require "uri"
require "net/http"

url = URI("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fwww.apple.com%2F&fresh=true&[OPTIONS]")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)

response = https.request(request)
puts response.read_body
```

## Fresh

**Parameter Name :** `fresh`

By default, every request you make captures a brand-new render of the target URL. However, if the same URL has been processed before with `enable_caching`, ScreenshotAPI stores that result in cache. The fresh parameter gives you control over whether the API should ignore that cache and re-render the page, or simply return the previously stored version - saving time and resources when an up-to-date capture isn't necessary.

**Options**

*   **true:** Bypasses the cache entirely and captures a fresh, up-to-date render of the page on every request.
    
*   **false:** Returns the cached version if one exists, skipping the rendering process for faster response times.
    

**When to use**

*   Use `true` when the page content changes frequently and accuracy matters - such as live dashboards, news pages, or real-time data feeds.
    
*   Use `false` when speed and efficiency are the priority and a slightly older snapshot is acceptable - ideal for static pages, bulk jobs, or preview thumbnails.
    

**Default value:**`true`.

## Enable Caching

**Parameter Name :** `enable_caching`

The `enable_caching` parameter allows you to control whether a generated screenshot, render, or PDF should be stored for reuse in future requests. When enabled, the first request captures a fresh render of the target URL and saves it in the cache. Any subsequent requests with the same URL and parameters can then reuse this cached version instead of generating a new one, significantly improving performance and reducing API processing time.

**Options**

*   **true:** Stores the generated screenshot or render in cache, making it available for reuse in future requests with the same parameters.
    
*   **false:** Does not store the result in cache. Every request will generate a new render, regardless of previous requests.
    

**When to use**

This is especially useful for workflows where the same pages are requested multiple times, as it minimizes redundant rendering, optimizes resource usage, and returns results much faster. Additionally, when a cached screenshot is served, it does not consume extra credit, making it a cost-efficient option for repeated requests.

**Default value:**`false`.

## TTL (Time to Live)

**Parameter Name :** `ttl`

The ttl (Time to Live) parameter defines how long a screenshot should remain stored in the cache before it expires. It is specified in seconds and determines the lifespan of cached content. Once the TTL duration is reached, the cached version is automatically invalidated, and a new screenshot will be generated on the next request (if caching is enabled).

This gives you fine control over how frequently your content should be refreshed, allowing you to balance between performance (using cached results) and accuracy (fetching updated renders).

**Options**

Set any numeric value in seconds (e.g., 3600 for 1 hour, 86400 for 1 day).

**When to use**

*   Use a `higher TTL` when working with static or rarely changing pages to maximize cache usage, reduce API load, and avoid unnecessary re-renders.
    
*   Use a `lower TTL` when dealing with dynamic content that updates frequently, ensuring that cached screenshots expire sooner and fresh data is captured more often.
    

**Default value:**`2592000`seconds (30 days).
